Excel.SearchCriteria interface

表示要使用的搜索条件。

注解

API 集:ExcelApi 1.9

使用方

示例

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);
    }
});

属性

completeMatch

指定匹配是需要完整匹配还是部分匹配。 完全匹配与单元格的整个内容匹配。 部分匹配与单元格内容中的子字符串匹配 (例如, cat 部分匹配 caterpillarscatter) 。 默认值为 false (部分) 。

matchCase

指定匹配项是否区分大小写。 默认值 (false 不区分大小写) 。

searchDirection

指定搜索方向。 默认值为向前。 请参阅 Excel.SearchDirection

属性详细信息

completeMatch

指定匹配是需要完整匹配还是部分匹配。 完全匹配与单元格的整个内容匹配。 部分匹配与单元格内容中的子字符串匹配 (例如, cat 部分匹配 caterpillarscatter) 。 默认值为 false (部分) 。

completeMatch?: boolean;

属性值

boolean

注解

API 集:ExcelApi 1.9

matchCase

指定匹配项是否区分大小写。 默认值 (false 不区分大小写) 。

matchCase?: boolean;

属性值

boolean

注解

API 集:ExcelApi 1.9

searchDirection

指定搜索方向。 默认值为向前。 请参阅 Excel.SearchDirection

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

属性值

Excel.SearchDirection | "Forward" | "Backwards"

注解

API 集:ExcelApi 1.9