Excel.SearchCriteria interface
Represents the search criteria to be used.
Remarks
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
| complete |
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., |
| match |
Specifies if the match is case-sensitive. Default is |
| search |
Specifies the search direction. Default is forward. See |
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
matchCase
Specifies if the match is case-sensitive. Default is false (case-insensitive).
matchCase?: boolean;
Property Value
boolean
Remarks
searchDirection
Specifies the search direction. Default is forward. See Excel.SearchDirection.
searchDirection?: Excel.SearchDirection | "Forward" | "Backwards";
Property Value
Excel.SearchDirection | "Forward" | "Backwards"