Last active
November 16, 2024 17:07
-
-
Save bantunesm/c93fce37f0fb1891d32e0e685996fa7a to your computer and use it in GitHub Desktop.
Scriptable widget Google Sheets for iOS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let spreadsheetid = "ID Spreadsheet" | |
let sheetname = "Sheet Name" | |
let apikey = "COMPLETE" // Activate Google Sheets Service | |
const endpoint = 'https://sheets.googleapis.com/v4/spreadsheets/' + spreadsheetid + '/values/' + sheetname + '?alt=json&key=' + apikey; | |
console.log(endpoint) | |
// The URL of your JSON endpoint | |
// endpoint JSON | |
async function loadItems() { | |
let at = endpoint | |
let req = new Request(at) | |
let corpo = await req.loadJSON() | |
// We return just the cells | |
return corpo | |
} | |
// Requete data | |
let json = await loadItems() | |
// Getter | |
PatrimoineMonthValue = json.values[1][1] | |
PatrimoineNetValue = json.values[0][2] | |
PatrimoineBrutValue = json.values[2][2] | |
// Creation widget | |
let w = new ListWidget() | |
w.backgroundColor = new Color("#cfddff") | |
// Ajout data | |
let preTxt = w.addText("💰 Patrimoine") | |
preTxt.textColor = new Color("#000") | |
// preTxt.textOpacity = 0.8 | |
preTxt.font = Font.mediumSystemFont(14) | |
w.addSpacer(10) | |
t = w.addText("M: " + PatrimoineMonthValue) | |
t.textColor = Color.darkGray() | |
t.font = Font.mediumSystemFont(14) | |
w.addSpacer(3) | |
tm = w.addText("N: " + PatrimoineNetValue) | |
tm.textColor = new Color("#3866D3") | |
tm.font = Font.mediumSystemFont(14) | |
w.addSpacer(3) | |
tb = w.addText("B: " + PatrimoineBrutValue) | |
tb.textColor = new Color("#5938d3") | |
tb.font = Font.mediumSystemFont(14) | |
Script.setWidget(w) | |
Script.complete() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment