Skip to content

Instantly share code, notes, and snippets.

View theGove's full-sized avatar

theGove

View GitHub Profile
@theGove
theGove / Invoice_complete_example.js
Last active February 21, 2022 15:03
A complete example to build an invoice and fetch data from an API endpoint
function launch_show_form(){
/*Jade.listing:{"name":"Show invoice form","description":"Displays a form to manage the invoice example."}*/
show_form()
}
function fetch_json(params){
if(!params.on_fail){params.on_fail=fetch_failed}
fetch(params.url)
@theGove
theGove / cell_buttons.js
Created January 1, 2022 11:42
Format Cells to behave like Buttons in Excel uising Office-js
function build_buttons(){
/*Jade.listing:{"name":"Build Buttons","description":"Format cells on the active sheet to appear as buttons"}*/
Excel.run(async function (context) {
const sheet = context.workbook.worksheets.getActiveWorksheet()
// set column sizes for cells to look like buttons
sheet.getRange("A1").format.columnWidth=10
sheet.getRange("B1").format.columnWidth=50
sheet.getRange("C1").format.columnWidth=10
sheet.getRange("D1").format.columnWidth=50
@theGove
theGove / range-tools.js
Last active February 21, 2022 15:02
Tools to help with the building of Excel myEducator assignments
function auto_exec(){
Jade.add_library("https://cdnjs.cloudflare.com/ajax/libs/yamljs/0.3.0/yaml.min.js")
const html=[]
html.push('<button onclick="showRangeForm()">Range Tools</button> ')
html.push('<button onclick="showRangeForm()">Task Tools</button> ')
Jade.open_canvas("Index", html.join(""))
}
//change and it is changed
@theGove
theGove / export_tsv.js
Last active February 21, 2022 15:02
A JADE module to export the active worksheet as a tab-separated-variable file
function auto_exec(){
const data=[
{action:"Excel.run(save_as_tsv)",
name:"Save as TSV",
description:"Saves the data on the active sheet as a tab-seaparated-varible file"}
]
Jade.open_automations(true, "Automations", data)
}
async function save_as_tsv(excel){
@theGove
theGove / download_pdf.js
Last active February 21, 2022 15:02
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')
@theGove
theGove / airtable_data.js
Last active February 21, 2022 15:01
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"
const table="member"
@theGove
theGove / dw_tools.js
Last active February 21, 2022 15:01
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,
},
@theGove
theGove / airtable_tools.js
Last active February 21, 2022 14:55
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
@theGove
theGove / excel_tools.js
Last active February 21, 2022 15:00
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)
@theGove
theGove / data_world.js
Created January 4, 2022 20:46
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'