Created
May 18, 2019 03:00
-
-
Save areed1192/75e406b0e5059e23ec9158378875cdc0 to your computer and use it in GitHub Desktop.
This program will select a range of cells and perform some formatting.
This file contains hidden or 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: MyFirstJavaScript Program | |
| description: This program will select a range of cells and perform some formatting. | |
| host: EXCEL | |
| api_set: {} | |
| script: | |
| content: | | |
| /* | |
| * let's assign a function to our run button | |
| * in this case on the 'Click' event we will | |
| * execute our 'Run' function and wrap it in our | |
| * tryCatch function so that way any errors that | |
| * are caught are notified to us. | |
| */ | |
| $("#run").click(() => tryCatch(highlightCell)); | |
| /** 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); | |
| } | |
| } | |
| async function highlightCell() { | |
| await Excel.run(async (context) => { | |
| /* Grab the selected Range */ | |
| var selectedRange = context.workbook.getSelectedRange(); | |
| /* set the fill color to blue */ | |
| selectedRange.format.fill.color = "#4472C4"; | |
| /* set the font color to white */ | |
| selectedRange.format.font.color = "white"; | |
| /* autofit the columns */ | |
| selectedRange.format.autofitColumns(); | |
| }); | |
| } | |
| language: typescript | |
| template: | |
| content: | | |
| <button id="run" class="ms-Button"> | |
| <span class="ms-Button-label">Run</span> | |
| </button> | |
| language: html | |
| style: | |
| content: | | |
| /* Your style goes here */ | |
| 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 | |
| @microsoft/[email protected]/dist/office.helpers.min.js | |
| @microsoft/[email protected]/dist/office.helpers.d.ts | |
| [email protected] | |
| @types/[email protected] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment