Created
October 30, 2020 19:37
-
-
Save andyweiss1982/9d272c0fcda475d0ccf850305c9228aa to your computer and use it in GitHub Desktop.
Very basic implementation of fetching data and putting into Excel
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
name: Dad Joke API Example | |
description: Very basic implementation of fetching data and putting into Excel | |
host: EXCEL | |
api_set: {} | |
script: | |
content: | | |
const button = document.querySelector("button"); | |
button.addEventListener("click", run); | |
async function getRandomDadJoke(){ | |
const response = await fetch("https://icanhazdadjoke.com/", { | |
headers: { | |
Accept: "application/json" | |
} | |
}) | |
const data = await response.json() | |
return data.joke | |
} | |
async function run() { | |
const joke = await getRandomDadJoke() | |
await Excel.run(async (context) => { | |
const sheet = context.workbook.worksheets.getActiveWorksheet(); | |
const range = sheet.getRange("A1"); | |
range.values = [[joke]]; | |
range.format.autofitColumns(); | |
await context.sync(); | |
}); | |
} | |
language: typescript | |
template: | |
content: |- | |
<h1>Want to hear a funny joke?</h1> | |
<button id="run">Get Joke</button> | |
language: html | |
style: | |
content: |- | |
h1 { | |
color: blue; | |
} | |
language: css | |
libraries: | | |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
@types/office-js | |
[email protected]/dist/css/fabric.min.css | |
[email protected]/dist/css/fabric.components.min.css | |
[email protected]/client/core.min.js | |
@types/core-js | |
[email protected] | |
@types/[email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment