Skip to content

Instantly share code, notes, and snippets.

@excript
Created June 29, 2023 03:35
Show Gist options
  • Save excript/fe2de8b0ced899d092a2462c838d5ca4 to your computer and use it in GitHub Desktop.
Save excript/fe2de8b0ced899d092a2462c838d5ca4 to your computer and use it in GitHub Desktop.
name: Botão
description: ''
host: EXCEL
api_set: {}
script:
content: |
$("#get-active-cell").click(() => tryCatch(run));
async function run() {
await Excel.run(async (context) => {
let myWorkbook = context.workbook;
let activeCell = myWorkbook.getActiveCell();
activeCell.load("address");
await context.sync();
console.log("The active cell is " + activeCell.address);
});
}
/** 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: "<section class=\"ms-font-m\">\n\t<p>This sample shows how to get the active cell of the entire workbook.</p>\n</section>\n\n<section class=\"samples ms-font-m\">\n\t<h3>Try it out</h3>\n\t<button id=\"get-active-cell\" class=\"ms-Button\">\n <span class=\"ms-Button-label\">Get active cell</span>\n </button>\n\n\t<button py-click=\"aaa()\" id=\"get-time\" class=\"py-button\">Get current time</button>\n</section>\n\n\n<py-script>\n\tprint(\"Ola mundo\")\n\n\tdef aaa():\n\tprint(\"aaaaa\")\n\tprint(\"aaaaa\")\n\tprint(\"aaaaa\")\n\tprint(\"aaaaa\")\n\tprint(\"aaaaa\")\n</py-script>\n\n<py-repl id=\"my-repl\" auto-generate=\"true\"> </py-repl>"
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/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
[email protected]
@types/[email protected]
https://pyscript.net/latest/pyscript.js
@types/[email protected]
https://pyscript.net/latest/pyscript.css
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment