Office Scripts in Excel code example
Example 1: excel office scripts documentation
async function main(context: Excel.RequestContext) {
let dateRange = context.workbook.worksheets.getActiveWorksheet().getRange("A1");
let timeRange = context.workbook.worksheets.getActiveWorksheet().getRange("B1");
let date = new Date(Date.now());
dateRange.values = [[date.toLocaleDateString()]];
timeRange.values = [[date.toLocaleTimeString()]];
}
Example 2: excel office scripts documentation
async function main(context: Excel.RequestContext) {
let selectedSheet = context.workbook.worksheets.getActiveWorksheet();
let range = selectedSheet.getRange("A1");
range.load("values");
await context.sync();
console.log(range.values);
}