Created
April 26, 2018 09:41
-
-
Save lumine2008/ed188fbdbf6231f41af0707c1a6c9116 to your computer and use it in GitHub Desktop.
Executes a basic Excel API call - 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: Basic API call | |
description: Executes a basic Excel API call | |
author: lumine2008 | |
host: EXCEL | |
api_set: {} | |
script: | |
content: | | |
$("#run").click(() => tryCatch(run)); | |
async function run() { | |
await Excel.run(async (context) => { | |
const range = context.workbook.getSelectedRange(); | |
range.format.fill.color = "red"; | |
range.load("address"); | |
await context.sync() | |
console.log(`The range address was "${range.address}".`); | |
}); | |
} | |
/** 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">Run code</span> | |
</button> | |
language: html | |
style: | |
content: '' | |
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