Skip to content

Instantly share code, notes, and snippets.

@jade-addin
jade-addin / invoice_complete_example.js
Last active January 6, 2022 16:17
Automatically running complete example of the Invoice genrator
const html_get_4x=`
<div id="div-4x" style="border: 1px solid; box-shadow: 5px 5px darkgrey;border-radius:.5rem;max-width:400px; background-color:white;display:none;margin:2rem;padding:1rem">
<div style="margin-bottom:1rem;font-size:1.5rem;font-weight:bold">Foreign Exchange</div>
Convert this invoice to currency of the customer's country.<br><br>This requires a free API key from <a href="https://www.alphavantage.co/" target="_blank">Alpha Vantage</a>.<br><br>
API Key: <input id="api-key-4x" size="10" /> <br><br><button onClick="jade_modules.invoice_complete_example.configure_4x()">Convert</button>
</div>`
const html_toggle_4x=`
<div id="div-4x-toggle" style="border: 1px solid; box-shadow: 5px 5px darkgrey;border-radius:.5rem;max-width:400px; background-color:white;display:none;margin:2rem;padding:1rem">
<div style="margin-bottom:1rem;font-size:1.5rem;font-weight:bold">Foreign Exchange</div>
@jade-addin
jade-addin / download_pdf.js
Created January 6, 2022 15:44
A JADE module to download a pdf of the currently selected range
function auto_exec(){
Jade.open_automations(true, "Automations", [
{action:"Excel.run(make_pdf)",
name:"Make a PDF",
description:"Builds and downloads a PDF file"}
])
Jade.add_library('https://cdn.jsdelivr.net/npm/pdfmake@latest/build/pdfmake.min.js')
Jade.add_library('https://cdn.jsdelivr.net/npm/pdfmake@latest/build/vfs_fonts.min.js')
@jade-addin
jade-addin / excel_tools.js
Last active January 7, 2022 16:54
Tools for working with Excel in the JADE environment
class excel_tools{
static async array_to_table(sheet_name, address, range_data){
const start_row = excel_tools.row_from_address(address)
const start_col = excel_tools.column_from_address(address)
await Excel.run(async function(excel){
var sheet = excel.workbook.worksheets.getItemOrNullObject(sheet_name);
await excel.sync()
if (sheet.isNullObject) {
sheet = excel.workbook.worksheets.add(sheet_name)
@jade-addin
jade-addin / dw_tools.js
Last active January 7, 2022 15:38
Tools for integrating JADE with data.world
jade.use("excel_tools")
class dw_tools{
static async query(query, id, owner, token, sheet_name, address){
const url=`https://api.data.world/v0/sql/${owner}/${id}`
const options={
headers: {
'Content-Type' : 'application/json',
'Authorization': 'Bearer ' + token,
},
@jade-addin
jade-addin / airtable_tools.js
Created January 6, 2022 15:38
Tools for integrating JADE with airtable
jade.use("excel_tools")
class airtable_tools{
static async query(base_id, table, token, fields, filter_formula, sheet_name, address){
const data=await airtable_tools.get_airtable_data(base_id, token, table, filter_formula,fields)
if(!fields){
fields=[]
//fields were not specified so we must scan all the data to find the complete set of fields
@jade-addin
jade-addin / data_world.js
Created January 6, 2022 15:37
JADE module to pull in data from Data.world
async function dw_query(){
await jade.use("dw_tools")
// specify the query
const query='select * from episode limit 3'
// information to access the right data set
const token="YOUR READ/WRITE TOKEN GOES HERE"
const id='simpsons'
const owner='atlas-query'
@jade-addin
jade-addin / airtable_data.js
Last active January 6, 2022 18:42
JADE module to pull data from Airtable
async function airtable_query(){
await jade.use("airtable_tools")
// infomration about where to place data
const sheet_name="MEMBER2"
const address="b2"
const token="YOUR API KEY GOES HERE"//https://airtable.com/account
const base_id= "appACNRk6PmArvtj1" // replace with a base ID from https://airtable.com/api
const table="member" // replace with your table name
@jade-addin
jade-addin / sort_sheets.js
Created January 6, 2022 14:24
A JADE module with a function to alphabetize worksheet order in an excel workbook
async function create_sheets(excel){
/*Jade.listing:{"name":"Create Worksheets","description":"Generate 10 sheets named for differnt kinds of apples"}*/
excel.workbook.worksheets.add("Evercrisp")
excel.workbook.worksheets.add("Braeburn")
excel.workbook.worksheets.add("Fuji")
excel.workbook.worksheets.add("Honeycrisp")
excel.workbook.worksheets.add("Ambrosia")
excel.workbook.worksheets.add("Gala")
excel.workbook.worksheets.add("Idared")
excel.workbook.worksheets.add("Cameo")
@jade-addin
jade-addin / Invoice_complete_example.js
Last active January 6, 2022 14:15
A complete example to build an invoice and fetch data from an API endpoint
const html_get_4x=`
<div id="div-4x" style="border: 1px solid; box-shadow: 5px 5px darkgrey;border-radius:.5rem;max-width:400px; background-color:white;display:none;margin:2rem;padding:1rem">
<div style="margin-bottom:1rem;font-size:1.5rem;font-weight:bold">Foreign Exchange</div>
Convert this invoice to currency of the customer's country.<br><br>This requires a free API key from <a href="https://www.alphavantage.co/" target="_blank">Alpha Vantage</a>.<br><br>
API Key: <input id="api-key-4x" size="10" /> <br><br><button onClick="jade_modules.invoice_complete_example.configure_4x()">Convert</button>
</div>`
const html_toggle_4x=`
<div id="div-4x-toggle" style="border: 1px solid; box-shadow: 5px 5px darkgrey;border-radius:.5rem;max-width:400px; background-color:white;display:none;margin:2rem;padding:1rem">
<div style="margin-bottom:1rem;font-size:1.5rem;font-weight:bold">Foreign Exchange</div>
@jade-addin
jade-addin / 01_Add_a_worksheet.js
Last active May 5, 2025 11:02
Invoice Examples: These examples show the steps of building an invoice in Excel
/*Make a worksheet with a name of "Invoice"*/
async function add_a_worksheet(excel) {
// This example will fail if there is already a
// worksheet named "Invoice"
const sheet = excel.workbook.worksheets.add("Invoice")
sheet.activate()
await excel.sync();
}