Last active
January 2, 2018 07:08
-
-
Save auqffniw/dda5fa05f1829fa9c311bebe2fce059a to your computer and use it in GitHub Desktop.
与Script Lab共享
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: 调试一个网友小代码 | |
description: '' | |
author: auqffniw | |
host: EXCEL | |
api_set: {} | |
script: | |
content: | | |
$("#run").click(() => tryCatch(run)); | |
async function run() { | |
await Excel.run(async (context) => { | |
var i | |
,cel; | |
const sht = context.workbook.worksheets.getItem("Sheet2"); | |
var rng = sht.getRange("AV3:AV22"); | |
rng.load("cellCount"); | |
rng.load("values"); | |
await context.sync(); | |
for (i = 0; i < rng.cellCount;i++) { | |
cel = rng.getCell(i, 0); | |
cel.getOffsetRange(0, 3).values = [[typeof (rng.values[i][0]+"") + " : " + rng.values[i][0]]] ; | |
//cel.getOffsetRange(0, 3).values = [[cel.values[0][0]]]; | |
var bl = /.*已完成.*/.test(rng.values[i][0]+""); | |
var bl2 = /.*已完成.*/.test("s已完成d"); | |
cel.getOffsetRange(0, 4).values = [[bl]]; | |
cel.getOffsetRange(0, 5).values = [[bl2]]; | |
if (bl) { | |
cel.getOffsetRange(0, 2).values = [[Date.now]]; | |
} else { | |
cel.getOffsetRange(0, 2).values = [["asdf"]]; | |
}; | |
} | |
await context.sync(); | |
}); | |
} | |
/** 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: | | |
<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: | | |
https://appsforoffice.microsoft.com/lib/1/hosted/office.js | |
https://appsforoffice.microsoft.com/lib/1/hosted/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 | |
@microsoft/office-js-helpers@0.7.4/dist/office.helpers.min.js | |
@microsoft/office-js-helpers@0.7.4/dist/office.helpers.d.ts | |
jquery@3.1.1 | |
@types/jquery |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment