Last active
January 27, 2021 05:47
-
-
Save lumine2008/1b5fcabc2a194fa9d2962028406d564d to your computer and use it in GitHub Desktop.
Performs a basic Excel API call using TypeScript.
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: PartnerCall-onFormulaChanged Event | |
description: Performs a basic Excel API call using TypeScript. | |
host: EXCEL | |
api_set: {} | |
script: | |
content: "$(\"#run\").click(() => tryCatch(run));\n\nasync function run() {\n await Excel.run(async (context) => {\n registerOnFormulaChangedHandler();\n\n });\n}\n\nasync function registerOnFormulaChangedHandler() {\n Excel.run(async function (context) {\n const ws = context.workbook.worksheets;\n\n let sheet = ws.getActiveWorksheet();\n sheet.onFormulaChanged.add(onFormulaChange);\n await context.sync();\n console.log(\"Added\_a\_worksheet-level\_formula changed\_event\_handler sucessfully.\");\n });\n}\n\nasync function onFormulaChange(event) {\n await Excel.run(async (context) => {\n console.log(event);\n });\n}\n\n\n/** Default helper for invoking an action and handling errors. */\nasync function tryCatch(callback) {\n try {\n await callback();\n } catch (error) {\n // Note: In a production add-in, you'd want to notify the user through your add-in's UI.\n console.error(error);\n }\n}\n" | |
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\">Try worksheet formula changed event.</p>\n\t<button id=\"run\" class=\"ms-Button\">\n <span class=\"ms-Button-label\">Register formula changed event</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/beta/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