Last active
March 3, 2021 12:48
-
-
Save lumine2008/ce36acd9cd7d9c45c990c1c897572d5e to your computer and use it in GitHub Desktop.
Performs a basic Excel API call using plain JavaScript & Promises.
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: DelayForCellEdit - Timer | |
description: Performs a basic Excel API call using plain JavaScript & Promises. | |
host: EXCEL | |
api_set: {} | |
script: | |
content: | | |
let val; | |
const refresh = async () => { | |
console.log("change detected"); | |
await Excel.run({ delayForCellEdit: true }, async (context) => { | |
try { | |
console.log("in run"); | |
const sheet = context.workbook.worksheets.getItem("Sheet1"); | |
const range = sheet.getRange("A1"); | |
range.load("values, range/format"); | |
await context.sync(); | |
if (range.values[0][0] !== val) { | |
console.log(range.values[0][0]); | |
val = range.values[0][0]; | |
if (range.values[0][0] === "f") { | |
range.format.fill.color = "red"; | |
} else { | |
range.format.fill.color = "blue"; | |
} | |
await context.sync(); | |
} | |
} catch (e) { | |
console.log(e); | |
} | |
}); | |
}; | |
Excel.run(async (context) => { | |
var myVar = setInterval(refresh, 2000); | |
await context.sync(); | |
}); | |
language: typescript | |
template: | |
content: "<section class=\"ms-font-m\">\n\t<p class=\"ms-font-m\">This sample demonstrates basic Excel API calls.</p>\n</section>\n\n<section class=\"samples ms-font-m\">\n\t<h3>Try it out</h3>\n\t<p class=\"ms-font-m\">Select some cells in the worksheet, then press <b>Highlight selected range</b>.</p>\n\t<button id=\"run\" class=\"ms-Button\">\n <span class=\"ms-Button-label\">Highlight selected range</span>\n </button>\n</section>" | |
language: html | |
style: | |
content: |- | |
section.samples { | |
margin-top: 20px; | |
} | |
section.samples .ms-Button, section.setup .ms-Button { | |
display: block; | |
margin-bottom: 5px; | |
margin-left: 20px; | |
min-width: 80px; | |
} | |
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