Check out example codes for "excel office scripts documentation". It will help you in understanding the concepts better.

Code Example 1

async function main(context: Excel.RequestContext) {
  // Get the cells at A1 and B1.
  let dateRange = context.workbook.worksheets.getActiveWorksheet().getRange("A1");
  let timeRange = context.workbook.worksheets.getActiveWorksheet().getRange("B1");

  // Get the current date and time with the JavaScript Date object.
  let date = new Date(;

  // Add the date string to A1.
  dateRange.values = [[date.toLocaleDateString()]];
  // Add the time string to B1.
  timeRange.values = [[date.toLocaleTimeString()]];

Code Example 2

async function main(context: Excel.RequestContext) {
  // Get the current worksheet.
  let selectedSheet = context.workbook.worksheets.getActiveWorksheet();

  // Get the value of cell A1.
  let range = selectedSheet.getRange("A1");
  await context.sync();

  // Print the value of A1.

Learn ReactJs, React Native from