Edit

Excel.SearchCriteria interface

Represents the search criteria to be used.

Remarks

API set: ExcelApi 1.9

Used by

Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const table = sheet.tables.getItem("ExpensesTable");
    const searchRange = table.getRange();
    
    // Search for cells that exactly match "TODO", ignoring case, and starting from the top-left of the range and going forward.
    const searchCriteria: Excel.SearchCriteria = {
        completeMatch: true,
        matchCase: false,
        searchDirection: Excel.SearchDirection.forward
    };
    const foundRange = searchRange.findOrNullObject("TODO", searchCriteria);
    foundRange.load("address");
    await context.sync();

    if (foundRange.isNullObject) {
        console.log("Text not found");
    } else {
        console.log(foundRange.address);
    }
});

Properties

completeMatch

Specifies if the match needs to be complete or partial. A complete match matches the entire contents of the cell. A partial match matches a substring within the content of the cell (e.g., cat partially matches caterpillar and scatter). Default is false (partial).

matchCase

Specifies if the match is case-sensitive. Default is false (case-insensitive).

searchDirection

Specifies the search direction. Default is forward. See Excel.SearchDirection.

Property Details

completeMatch

Specifies if the match needs to be complete or partial. A complete match matches the entire contents of the cell. A partial match matches a substring within the content of the cell (e.g., cat partially matches caterpillar and scatter). Default is false (partial).

completeMatch?: boolean;

Property Value

boolean

Remarks

API set: ExcelApi 1.9

matchCase

Specifies if the match is case-sensitive. Default is false (case-insensitive).

matchCase?: boolean;

Property Value

boolean

Remarks

API set: ExcelApi 1.9

searchDirection

Specifies the search direction. Default is forward. See Excel.SearchDirection.

searchDirection?: Excel.SearchDirection | "Forward" | "Backwards";

Property Value

Excel.SearchDirection | "Forward" | "Backwards"

Remarks

API set: ExcelApi 1.9