Skip to content

Instantly share code, notes, and snippets.

@lumine2008
Created October 17, 2018 06:02
Show Gist options
  • Save lumine2008/765bbb006433bd6195624118848709b1 to your computer and use it in GitHub Desktop.
Save lumine2008/765bbb006433bd6195624118848709b1 to your computer and use it in GitHub Desktop.
Executes a basic Excel API call - Shared with Script Lab
name: AutoUpdate Data
description: Executes a basic Excel API call
author: lumine2008
host: EXCEL
api_set: {}
script:
content: |
$("#run").click(() => tryCatch(run));
function callMyself() {
reCal();
setTimeout(callMyself, 1000);
}
async function run() {
setTimeout(callMyself, 2000);
}
async function reCal()
{
await Excel.run(async (context) => {
context.workbook.application.calculate(Excel.CalculationType.recalculate);
await context.sync();
});
}
/** Default helper for invoking an action and handling errors. */
async function tryCatch(callback) {
try {
await callback();
}
catch (error) {
OfficeHelpers.UI.notify(error);
OfficeHelpers.Utilities.log(error);
}
}
language: typescript
template:
content: |
<p class="ms-font-m">Executes a simple code snippet.</p>
<button id="run" class="ms-Button">
<span class="ms-Button-label">Connect </span>
</button>
language: html
style:
content: ''
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
@microsoft/[email protected]/dist/office.helpers.min.js
@microsoft/[email protected]/dist/office.helpers.d.ts
[email protected]
@types/jquery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment