Created
April 15, 2021 18:08
-
-
Save dmishin/0ca3ace1f50869a505921f213cb1a1b6 to your computer and use it in GitHub Desktop.
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
$("#run").click(() => tryCatch(run)); | |
async function run() { | |
Excel.run(async function (context) { | |
var sctivesheet = context.workbook.worksheets.getActiveWorksheet(); | |
var table = sctivesheet.tables.add(sctivesheet.getRangeByIndexes(0, 0, 1, 2), true); | |
var data = [[1, "A"], [2, "B"], [3, "C"]]; | |
table.rows.add(0, data); | |
}).catch(function (error) { | |
console.log("Error: " + error); | |
} ) | |
} | |
/** 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); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
A gist for this problem with Excel JS addons:
https://stackoverflow.com/questions/66891572/excel-web-addin-disappears-crashed-if-javascript-code-in-parallel-session-recr