Created
July 23, 2018 16:45
-
-
Save XiangGaoMSFT/f1c3c0d07728af8bd3ecb28d29d89abe to your computer and use it in GitHub Desktop.
Not verified yet - Shared with Script Lab
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: Issue of range.values | |
description: Not verified yet | |
author: xianggaomsft | |
host: EXCEL | |
api_set: {} | |
script: | |
content: | | |
$("#run").click(() => tryCatch(run)); | |
var yearRange; | |
async function run() { | |
await Excel.run(async (context) => { | |
var values = new Array(); | |
var sheet = context.workbook.worksheets.getActiveWorksheet(); | |
var range = sheet.getUsedRangeOrNullObject(); | |
range.load('columnCount,rowCount'); | |
return context.sync() | |
.then(function () { | |
for (var i = 0; i < 2; i++) { | |
var newRangeAdd = "D1:D37"; | |
var newRange = sheet.getRange(newRangeAdd); | |
newRange.insert("Right"); | |
} | |
}) | |
.then(context.sync) | |
.then(function () { | |
yearRange = sheet.getRange("D7:K7"); | |
values[0] = new Array(); | |
for (var i = 0; i < 8; i++) { | |
var value = "=A" + i; | |
values[0][i] = value; | |
} | |
yearRange.values = values; | |
}).then(context.sync) | |
.catch(function (e) { | |
console.log(e); | |
}); | |
}) | |
} | |
/** 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); | |
} | |
} | |
language: typescript | |
template: | |
content: | | |
<p class="ms-font-m">Executes a simple code snippet.</p> | |
<button id="run" class="ms-Button"> | |
<span class="ms-Button-label">Run code</span> | |
</button> | |
language: html | |
style: | |
content: '' | |
language: css | |
libraries: | | |
https://appsforoffice.microsoft.com/lib/beta/hosted/office.js | |
https://appsforoffice.microsoft.com/lib/beta/hosted/office.d.ts | |
[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/jquery |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment