Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$("#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);
}
}
@dmishin

This comment has been minimized.

Copy link
Owner Author

@dmishin dmishin commented Apr 15, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment