Created
July 19, 2021 02:54
-
-
Save ci010/2377df5985c3a633fc88c791f2cb98d5 to your computer and use it in GitHub Desktop.
For McGrillHill Online APIs
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: APIs Demo | |
description: For McGrillHill Online APIs | |
host: EXCEL | |
api_set: {} | |
script: | |
content: | | |
$("#addListeners").click(() => tryCatch(addListeners)); | |
async function addListeners() { | |
const start = Date.now(); | |
await Excel.run(async (context) => { | |
context.workbook.worksheets.onChanged.add(async (arg) => { | |
console.log(arg); | |
}); | |
context.workbook.worksheets.onMoved.add(async (arg) => { | |
console.log(arg); | |
}); | |
context.workbook.worksheets.onNameChanged.add(async (arg) => { | |
console.log(arg); | |
}); | |
console.log('Listeners added!') | |
}); | |
} | |
/** Default helper for invoking an action and handling errors. */ | |
async function tryCatch(callback) { | |
try { | |
await callback(); | |
} catch (error) { | |
// Note: In a production add-in, you'd want to notify the user through your add-in's UI. | |
console.error(error); | |
} | |
} | |
language: typescript | |
template: | |
content: "<div>Please setup listeners first: </div>\n<button id=\"addListeners\" class=\"ms-Button\" >\n <span class=\"ms-Button-label\">Add Listeners</span>\n</button>\n<div style=\"margin: 20px 0\">\n\tPlease try to\n\t<li> Rename worksheet and observe the printed event </li>\n\t<li> Move worksheet position and observe the printed event </li>\n\t<li> Insert/Delete cells and shift right/down in worksheet, and observe \"changeDirectionState\" in printed event </li>\n</div>\n<div>\n\tThis demo shows these new APIs:\n\t<li> Worksheet.onMoved event </li>\n\t<li> Worksheet.onRenamed event </li>\n\t<li> Worksheet.onChanged event's new \"changeDirectionState\" argument </li>\n</div>" | |
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://unpkg.com/@microsoft/office-js@1.1.71-custom.35/dist/office.js | |
https://unpkg.com/@microsoft/office-js@1.1.71-custom.35/dist/office.d.ts | |
office-ui-fabric-js@1.4.0/dist/css/fabric.min.css | |
office-ui-fabric-js@1.4.0/dist/css/fabric.components.min.css | |
core-js@2.4.1/client/core.min.js | |
@types/core-js | |
jquery@3.1.1 | |
@types/jquery@3.3.1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment