Last active
July 10, 2018 09:04
-
-
Save nikolay-borzov/c63494165a7dfebd41138ac335a6b3a9 to your computer and use it in GitHub Desktop.
Shared with Script Lab
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: Blank snippet | |
description: '' | |
author: nikolay-borzov | |
host: EXCEL | |
api_set: {} | |
script: | |
content: | | |
$("#runArray").click(() => tryCatch(runArray)); | |
async function runArray() { | |
await Excel.run(async context => { | |
const worksheets = context.workbook.worksheets; | |
worksheets.load(['items/id', 'items/name']); | |
await context.sync(); | |
worksheets.items.forEach(ws => OfficeHelpers.UI.notify(`id: ${ws.id}, name: ${ws.name}`)); | |
}); | |
} | |
$("#runString").click(() => tryCatch(runString)); | |
async function runString() { | |
await Excel.run(async context => { | |
const worksheets = context.workbook.worksheets; | |
worksheets.load('items/id, items/name'); | |
await context.sync(); | |
worksheets.items.forEach(ws => OfficeHelpers.UI.notify(`id: ${ws.id}, name: ${ws.name}`)); | |
}); | |
} | |
/** 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: |- | |
<button id="runArray" class="ms-Button"> | |
<span class="ms-Button-label">load(['items/id', 'items/name']</span> | |
</button> | |
<button id="runString" class="ms-Button"> | |
<span class="ms-Button-label">load('items/id, items/name')</span> | |
</button> | |
language: html | |
style: | |
content: | | |
/* Your style goes here */ | |
language: css | |
libraries: | | |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
https://appsforoffice.microsoft.com/lib/1/hosted/office.d.ts | |
[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