0

I just wonder whether we can find and replace using Office Excel JS? I have read through their doc but it does not mention about this functionality.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45

2 Answers2

0

The Range object has a find method to search for a specified string within the range. It returns the range of the first cell with matching text.

await Excel.run(async (context) => {
    let sheet = context.workbook.worksheets.getItem("Sample");
    let table = sheet.tables.getItem("ExpensesTable");
    let searchRange = table.getRange();
    let foundRange = searchRange.find("Food", {
        completeMatch: true, // Match the whole cell value.
        matchCase: false, // Don't match case.
        searchDirection: Excel.SearchDirection.forward // Start search at the beginning of the range.
    });

    foundRange.load("address");
    await context.sync();

    console.log(foundRange.address);
});

See Find a string within a range using the Excel JavaScript API for more information.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
0

This function replaceAll would do it

  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Aug 16 '22 at 11:04