Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Zlatkovsky/6bc4a7ab36a81be873697cab0fa0b653 to your computer and use it in GitHub Desktop.
Save Zlatkovsky/6bc4a7ab36a81be873697cab0fa0b653 to your computer and use it in GitHub Desktop.
name: '(StackOverflow 43972287): Set range to array of values'
description: 'http://stackoverflow.com/questions/43972287/assign-an-array-of-values-to-a-range'
author: Zlatkovsky
host: EXCEL
api_set: {}
script:
content: |
$("#run").click(run);
async function run() {
try {
const values = [
[1, 2, 3],
["Hello", "Bonjour", "Привет"]
]
await Excel.run(async (context) => {
const sheet = context.workbook.worksheets.getActiveWorksheet();
const range = sheet.getRange("D3").getResizedRange(
values.length - 1, values[0].length - 1);
range.values = values;
await context.sync();
});
}
catch (error) {
OfficeHelpers.UI.notify(error);
OfficeHelpers.Utilities.log(error);
}
}
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 */\r\n"
language: css
libraries: |
# Office.js
https://appsforoffice.microsoft.com/lib/1/hosted/office.js
# CSS Libraries
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
# NPM libraries
core-js@2.4.1/client/core.min.js
@microsoft/office-js-helpers@0.7.1/dist/office.helpers.min.js
jquery@3.1.1
# IntelliSense: @types/library or node_modules paths or URL to d.ts files
@types/office-js
@types/core-js
@microsoft/office-js-helpers@0.7.1/dist/office.helpers.d.ts
@types/jquery
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment