ExcelScript.SearchCriteria interface

表示要使用的搜索条件。

注解

示例

/**
 * This script searches for the next instance of the text "TK" on the current worksheet.
 * It then selects that cell and removes "TK" and all formatting from the cell.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the used range on the current worksheet.
  let range = workbook.getActiveWorksheet().getUsedRange();

  // Get the next cell that contains "TK".
  let tkCell = range.find("TK", {
    completeMatch: true, /* Don't match if the cell text only contains "TK" as part of another string. */
    matchCase: false,
    searchDirection: ExcelScript.SearchDirection.forward /* Start at the beginning of the range and go to later columns and rows. */
  });

  // Set focus on the found cell.
  tkCell.select();

  // Remove the "TK" text value from the cell, as well as any formatting that may have been added.
  tkCell.clear(ExcelScript.ClearApplyTo.all);
}

属性

completeMatch

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

matchCase

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

searchDirection

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

属性详细信息

completeMatch

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

completeMatch?: boolean;

属性值

boolean

matchCase

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

matchCase?: boolean;

属性值

boolean

searchDirection

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

searchDirection?: SearchDirection;

属性值