ExcelScript.ReplaceCriteria interface

使用する置換条件を表します。

プロパティ

completeMatch

一致が完全であるか部分的である必要があるかどうかを指定します。 完全一致は、セルの内容全体と一致します。 部分一致は、セルのコンテンツ内の部分文字列と一致します (たとえば、caterpillarscatterに部分的に一致cat)。 既定値は false (部分) です。

matchCase

一致で大文字と小文字が区別されるかどうかを指定します。 既定値は false です (大文字と小文字は区別されません)。

プロパティの詳細

completeMatch

一致が完全であるか部分的である必要があるかどうかを指定します。 完全一致は、セルの内容全体と一致します。 部分一致は、セルのコンテンツ内の部分文字列と一致します (たとえば、caterpillarscatterに部分的に一致cat)。 既定値は false (部分) です。

completeMatch?: boolean;

プロパティ値

boolean

/**
 * This script normalizes the text in a column so that values don't include both "OK" and "okay". 
 * It replaces "OK" and all the case-based variants with "okay".
 */ 
function main(workbook: ExcelScript.Workbook) {
  // Get the range representing column D.
  const currentSheet = workbook.getActiveWorksheet();
  const column = currentSheet.getRange("D:D");

  // Create a ReplaceCriteria object for the Range.replaceAll call.
  const criteria: ExcelScript.ReplaceCriteria = {
    completeMatch: true, /* Use a complete match to skip cells that already say "okay". */
    matchCase: false /* Ignore case when comparing strings. */
  };

  // Replace all instances of "ok" (case-insensitive) with "okay".
  column.replaceAll("ok", "okay", criteria);
}

matchCase

一致で大文字と小文字が区別されるかどうかを指定します。 既定値は false です (大文字と小文字は区別されません)。

matchCase?: boolean;

プロパティ値

boolean

/**
 * This script replaces instances of "NA" with "North America", 
 * using the casing to ignore parts of words.
 */ 
function main(workbook: ExcelScript.Workbook) {
  // Get the currently used range.
  const currentSheet = workbook.getActiveWorksheet();
  const usedRange = currentSheet.getUsedRange();

  // Create a ReplaceCriteria object for the Range.replaceAll call.
  const criteria: ExcelScript.ReplaceCriteria = {
    completeMatch: false, 
    matchCase: true /* Match with "NA market", not "navigate" */
  }

  // Replace all instances of "NA" (case-sensitive) with "North America".
  usedRange.replaceAll("NA", "North America", criteria);
}