Class ConditionalFormatRuleBuilder

ConditionalFormatRuleBuilder

条件付き書式設定ルールのビルダー。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they contain a number between 1 and 10.
const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenNumberBetween(1, 10)
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

メソッド

メソッド戻り値の型概要
build()ConditionalFormatRuleビルダーに適用された設定から条件付き書式ルールを構築します。
copy()ConditionalFormatRuleBuilderこのルールの設定を含むルールビルダーのプリセットを返します。
getBooleanCondition()BooleanConditionこのルールでブール条件の基準が使用されている場合、ルールの BooleanCondition 情報を取得します。
getGradientCondition()GradientConditionこのルールでグラデーション条件の基準が使用されている場合、ルールの GradientCondition 情報を取得します。
getRanges()Range[]この条件付き書式ルールが適用される範囲を取得します。
setBackground(color)ConditionalFormatRuleBuilder条件付き書式設定ルールの形式の背景色を設定します。
setBackgroundObject(color)ConditionalFormatRuleBuilder条件付き書式設定ルールの形式の背景色を設定します。
setBold(bold)ConditionalFormatRuleBuilder条件付き書式設定ルールの書式でテキストを太字にするかどうかを設定します。
setFontColor(color)ConditionalFormatRuleBuilder条件付き書式ルールの書式のフォントの色を設定します。
setFontColorObject(color)ConditionalFormatRuleBuilder条件付き書式ルールの書式のフォントの色を設定します。
setGradientMaxpoint(color)ConditionalFormatRuleBuilder条件付き書式ルールのグラデーションの最大値をクリアし、代わりにルールの範囲内の最大値を使用します。
setGradientMaxpointObject(color)ConditionalFormatRuleBuilder条件付き書式ルールのグラデーションの最大値をクリアし、代わりにルールの範囲内の最大値を使用します。
setGradientMaxpointObjectWithValue(color, type, value)ConditionalFormatRuleBuilder条件付き書式設定ルールのグラデーションの最大ポイント フィールドを設定します。
setGradientMaxpointWithValue(color, type, value)ConditionalFormatRuleBuilder条件付き書式設定ルールのグラデーションの最大ポイント フィールドを設定します。
setGradientMidpointObjectWithValue(color, type, value)ConditionalFormatRuleBuilder条件付き書式設定ルールのグラデーションの中間点フィールドを設定します。
setGradientMidpointWithValue(color, type, value)ConditionalFormatRuleBuilder条件付き書式設定ルールのグラデーションの中間点フィールドを設定します。
setGradientMinpoint(color)ConditionalFormatRuleBuilder条件付き書式ルールのグラデーションの中間点の値をクリアし、代わりにルールの範囲の最小値を使用します。
setGradientMinpointObject(color)ConditionalFormatRuleBuilder条件付き書式ルールのグラデーションの中間点の値をクリアし、代わりにルールの範囲の最小値を使用します。
setGradientMinpointObjectWithValue(color, type, value)ConditionalFormatRuleBuilder条件付き書式設定ルールのグラデーションの最小ポイント フィールドを設定します。
setGradientMinpointWithValue(color, type, value)ConditionalFormatRuleBuilder条件付き書式設定ルールのグラデーションの最小ポイント フィールドを設定します。
setItalic(italic)ConditionalFormatRuleBuilder条件付き書式設定ルールの書式でテキストを斜体に設定します。
setRanges(ranges)ConditionalFormatRuleBuilderこの条件付き書式ルールが適用される範囲を 1 つ以上設定します。
setStrikethrough(strikethrough)ConditionalFormatRuleBuilder条件付き書式設定ルールの書式にテキストの取り消し線を設定します。
setUnderline(underline)ConditionalFormatRuleBuilder条件付き書式設定ルールの書式にテキストの下線を設定します。
whenCellEmpty()ConditionalFormatRuleBuilderセルが空の場合にトリガーされる条件付き書式設定ルールを設定します。
whenCellNotEmpty()ConditionalFormatRuleBuilderセルが空でない場合にトリガーされる条件付き書式設定ルールを設定します。
whenDateAfter(date)ConditionalFormatRuleBuilder日付が指定された値より後の場合にトリガーされる条件付き書式ルールを設定します。
whenDateAfter(date)ConditionalFormatRuleBuilder指定された相対日付より後の日付になったときに条件付き書式ルールがトリガーされるように設定します。
whenDateBefore(date)ConditionalFormatRuleBuilder日付が指定された日付より前の場合にトリガーされる条件付き書式ルールを設定します。
whenDateBefore(date)ConditionalFormatRuleBuilder指定された相対日付より前の日付になったときにトリガーされる条件付き書式ルールを設定します。
whenDateEqualTo(date)ConditionalFormatRuleBuilder日付が指定された日付と等しい場合にトリガーされる条件付き書式設定ルールを設定します。
whenDateEqualTo(date)ConditionalFormatRuleBuilder日付が指定された相対日付と等しい場合にトリガーされる条件付き書式設定ルールを設定します。
whenFormulaSatisfied(formula)ConditionalFormatRuleBuilder指定された数式が true と評価されたときにトリガーされる条件付き書式設定ルールを設定します。
whenNumberBetween(start, end)ConditionalFormatRuleBuilder条件付き書式ルールを設定して、数値が 2 つの指定された値の間にあるか、いずれかの値と等しい場合にトリガーされるようにします。
whenNumberEqualTo(number)ConditionalFormatRuleBuilder数値が指定された値と等しい場合にトリガーされる条件付き書式ルールを設定します。
whenNumberGreaterThan(number)ConditionalFormatRuleBuilder数値が指定された値より大きい場合にトリガーされる条件付き書式ルールを設定します。
whenNumberGreaterThanOrEqualTo(number)ConditionalFormatRuleBuilder数値が指定された値以上の場合にトリガーされる条件付き書式ルールを設定します。
whenNumberLessThan(number)ConditionalFormatRuleBuilder指定された値より小さい数値の場合にトリガーされる条件付き書式設定ルールを設定します。
whenNumberLessThanOrEqualTo(number)ConditionalFormatRuleBuilder指定された値以下の数値の場合にトリガーされる条件付き書式ルールを設定します。
whenNumberNotBetween(start, end)ConditionalFormatRuleBuilder2 つの指定された値の間に数値が収まらず、どちらの値でもない場合にトリガーされる条件付き書式ルールを設定します。
whenNumberNotEqualTo(number)ConditionalFormatRuleBuilder数値が指定された値と等しくない場合にトリガーされる条件付き書式ルールを設定します。
whenTextContains(text)ConditionalFormatRuleBuilder入力に指定された値が含まれている場合にトリガーされる条件付き書式ルールを設定します。
whenTextDoesNotContain(text)ConditionalFormatRuleBuilder入力に指定された値が含まれていない場合にトリガーされる条件付き書式ルールを設定します。
whenTextEndsWith(text)ConditionalFormatRuleBuilder入力が指定された値で終わるときにトリガーされる条件付き書式ルールを設定します。
whenTextEqualTo(text)ConditionalFormatRuleBuilder入力が指定された値と等しい場合にトリガーされる条件付き書式ルールを設定します。
whenTextStartsWith(text)ConditionalFormatRuleBuilder入力が指定された値で始まる場合にトリガーされる条件付き書式ルールを設定します。
withCriteria(criteria, args)ConditionalFormatRuleBuilder条件付き書式ルールの条件を BooleanCriteria 値(通常は既存のルールの criteriaarguments から取得)で定義します。

詳細なドキュメント

build()

ビルダーに適用された設定から条件付き書式ルールを構築します。

戻る

ConditionalFormatRule - 条件付き書式ルールの表現。


copy()

このルールの設定を含むルールビルダーのプリセットを返します。

戻る

ConditionalFormatRuleBuilder - このルールの設定に基づくビルダー。


getBooleanCondition()

このルールでブール条件の基準が使用されている場合、ルールの BooleanCondition 情報を取得します。それ以外の場合は、null を返します。

// Log the boolean criteria type of the first conditional format rules of a
// sheet.
const rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];
const booleanCondition = rule.getBooleanCondition();
if (booleanCondition != null) {
  Logger.log(booleanCondition.getCriteriaType());
}

戻る

BooleanCondition - ブール条件オブジェクト。ルールでブール条件を使用しない場合は null


getGradientCondition()

このルールでグラデーション条件の基準が使用されている場合、ルールの GradientCondition 情報を取得します。それ以外の場合は、null を返します。

// Log the gradient minimum color of the first conditional format rule of a
// sheet.
const rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];
const gradientCondition = rule.getGradientCondition();
if (gradientCondition != null) {
  // Assume the color has ColorType.RGB.
  Logger.log(gradientCondition.getMinColorObject().asRgbColor().asHexString());
}

戻る

GradientCondition - グラデーション条件オブジェクト。ルールでグラデーション条件を使用しない場合は null


getRanges()

この条件付き書式ルールが適用される範囲を取得します。

// Log each range of the first conditional format rule of a sheet.
const rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];
const ranges = rule.getRanges();
for (let i = 0; i < ranges.length; i++) {
  Logger.log(ranges[i].getA1Notation());
}

戻る

Range[] - この条件付き書式ルールが適用される範囲。


setBackground(color)

条件付き書式設定ルールの書式の背景色を設定します。null を渡すと、ルールから背景色の形式設定が削除されます。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// set their background color to red if the cell has text equal to "hello".

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenTextEqualTo('hello')
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
colorString目的の色または null(クリア)。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setBackgroundObject(color)

条件付き書式設定ルールの書式の背景色を設定します。null を渡すと、ルールから背景色の形式設定が削除されます。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// set their background color to theme background color if the cell has text
// equal to "hello".

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const color = SpreadsheetApp.newColor()
                  .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND)
                  .build();
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenTextEqualTo('hello')
                 .setBackground(color)
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
colorColor目的の色オブジェクトまたはクリアする null

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setBold(bold)

条件付き書式設定ルールの書式でテキストを太字にするかどうかを設定します。boldtrue の場合、条件が満たされるとテキストが太字になります。false の場合、条件が満たされると既存の太字が削除されます。null を渡すと、ルールから太字形式の設定が削除されます。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn their text bold if the cell has text equal to "hello".

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenTextEqualTo('hello')
                 .setBold(true)
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
boldBoolean形式条件が満たされた場合にテキストを太字にするかどうか。null はこの設定を削除します。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setFontColor(color)

条件付き書式ルールの書式のフォントの色を設定します。null を渡すと、ルールからフォント色の形式設定が削除されます。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// set their font color to red if the cell has text equal to "hello".

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenTextEqualTo('hello')
                 .setFontColor('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
colorString目的の色または null(クリア)。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setFontColorObject(color)

条件付き書式ルールの書式のフォントの色を設定します。null を渡すと、ルールからフォント色の形式設定が削除されます。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// set their font color to theme text color if the cell has text equal to
// "hello".

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const color = SpreadsheetApp.newColor()
                  .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT)
                  .build();
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenTextEqualTo('hello')
                 .setFontColor(color)
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
colorColor目的の色オブジェクトまたはクリアする null

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setGradientMaxpoint(color)

条件付き書式ルールのグラデーションの最大値をクリアし、代わりにルールの範囲内の最大値を使用します。グラデーションの最大ポイントの色も入力色に設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// set their background color somewhere between white and red, based on their
// values in comparison to the ranges minimum and maximum values.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .setGradientMaxpoint('#FF0000')
                 .setGradientMinpoint('#FFFFFF')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
colorString設定する最大値の色。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setGradientMaxpointObject(color)

条件付き書式ルールのグラデーションの最大値をクリアし、代わりにルールの範囲内の最大値を使用します。グラデーションの最大ポイントの色も入力色に設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// set their background color somewhere between theme text and background
// colors, based on their values in comparison to the ranges minimum and maximum
// values.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const textColor = SpreadsheetApp.newColor()
                      .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT)
                      .build();
const backgroundColor =
    SpreadsheetApp.newColor()
        .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND)
        .build();
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .setGradientMaxpoint(textColor)
                 .setGradientMinpoint(backgroundColor)
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
colorColor設定する最大値の色オブジェクト。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setGradientMaxpointObjectWithValue(color, type, value)

条件付き書式設定ルールのグラデーションの最大ポイント フィールドを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// set their background color somewhere from theme accent 1, accent 2 to accent
// 3 colors, based on their values in comparison to the values 0, 50, and 100.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const color1 = SpreadsheetApp.newColor()
                   .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1)
                   .build();
const color2 = SpreadsheetApp.newColor()
                   .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2)
                   .build();
const color3 = SpreadsheetApp.newColor()
                   .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3)
                   .build();
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .setGradientMaxpointWithValue(
                     color1,
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '100',
                     )
                 .setGradientMidpointWithValue(
                     color2,
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '50',
                     )
                 .setGradientMinpointWithValue(
                     color3,
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '0',
                     )
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
colorColor設定する最大値の色。
typeInterpolationType設定する maxpoint 補間タイプ。
valueString設定する maxpoint 値。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setGradientMaxpointWithValue(color, type, value)

条件付き書式設定ルールのグラデーションの最大ポイント フィールドを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// set their background color somewhere from red green to blue, based on their
// values in comparison to the values 0, 50, and 100.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .setGradientMaxpointWithValue(
                     '#0000FF',
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '100',
                     )
                 .setGradientMidpointWithValue(
                     '#00FF00',
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '50',
                     )
                 .setGradientMinpointWithValue(
                     '#FF0000',
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '0',
                     )
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
colorString設定する最大値の色。
typeInterpolationType設定する maxpoint 補間タイプ。
valueString設定する maxpoint 値。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setGradientMidpointObjectWithValue(color, type, value)

条件付き書式設定ルールのグラデーションの中間点フィールドを設定します。渡された補間タイプが null の場合、すべての中間点フィールドをクリアします。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// set their background color somewhere from theme accent 1 to accent 2 to
// accent 3 colors, based on their values in comparison to the values 0, 50, and
// 100.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const color1 = SpreadsheetApp.newColor()
                   .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1)
                   .build();
const color2 = SpreadsheetApp.newColor()
                   .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2)
                   .build();
const color3 = SpreadsheetApp.newColor()
                   .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3)
                   .build();
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .setGradientMaxpointWithValue(
                     color1,
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '100',
                     )
                 .setGradientMidpointWithValue(
                     color2,
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '50',
                     )
                 .setGradientMinpointWithValue(
                     color3,
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '0',
                     )
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
colorColor設定する中央値の色。
typeInterpolationType設定する中間点補間タイプ。クリアする場合は null
valueString設定する中間点の値。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setGradientMidpointWithValue(color, type, value)

条件付き書式設定ルールのグラデーションの中間点フィールドを設定します。渡された補間タイプが null の場合、すべての中間点フィールドをクリアします。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// set their background color somewhere from red green to blue, based on their
// values in comparison to the values 0, 50, and 100.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .setGradientMaxpointWithValue(
                     '#0000FF',
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '100',
                     )
                 .setGradientMidpointWithValue(
                     '#00FF00',
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '50',
                     )
                 .setGradientMinpointWithValue(
                     '#FF0000',
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '0',
                     )
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
colorString設定する中央値の色。
typeInterpolationType設定する中間点補間タイプ。クリアする場合は null
valueString設定する中間点の値。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setGradientMinpoint(color)

条件付き書式ルールのグラデーションの中間点の値をクリアし、代わりにルールの範囲の最小値を使用します。また、グラデーションの最小ポイントの色を入力色に設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// set their background color somewhere between white and red, based on their
// values in comparison to the ranges minimum and maximum values.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .setGradientMaxpoint('#FF0000')
                 .setGradientMinpoint('#FFFFFF')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
colorString設定する最小値の色。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setGradientMinpointObject(color)

条件付き書式ルールのグラデーションの中間点の値をクリアし、代わりにルールの範囲の最小値を使用します。また、グラデーションの最小ポイントの色を入力色に設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// set their background color somewhere between theme text and background
// colors, based on their values in comparison to the ranges minimum and maximum
// values.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const textColor = SpreadsheetApp.newColor()
                      .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT)
                      .build();
const backgroundColor =
    SpreadsheetApp.newColor()
        .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND)
        .build();
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .setGradientMaxpoint(textColor)
                 .setGradientMinpoint(backgroundColor)
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
colorColor設定する最小値の色オブジェクト。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setGradientMinpointObjectWithValue(color, type, value)

条件付き書式設定ルールのグラデーションの最小ポイント フィールドを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// set their background color somewhere from theme accent 1 to accent 2 to
// accent 3 colors, based on their values in comparison to the values 0, 50, and
// 100.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const color1 = SpreadsheetApp.newColor()
                   .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1)
                   .build();
const color2 = SpreadsheetApp.newColor()
                   .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2)
                   .build();
const color3 = SpreadsheetApp.newColor()
                   .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3)
                   .build();
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .setGradientMaxpointWithValue(
                     color1,
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '100',
                     )
                 .setGradientMidpointWithValue(
                     color2,
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '50',
                     )
                 .setGradientMinpointWithValue(
                     color3,
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '0',
                     )
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
colorColor設定する最小値の色。
typeInterpolationType設定する最小ポイント補間タイプ。
valueString設定する minpoint 値。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setGradientMinpointWithValue(color, type, value)

条件付き書式設定ルールのグラデーションの最小ポイント フィールドを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// set their background color somewhere from red to green to blue, based on
// their values in comparison to the values 0, 50, and 100.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .setGradientMaxpointWithValue(
                     '#0000FF',
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '100',
                     )
                 .setGradientMidpointWithValue(
                     '#00FF00',
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '50',
                     )
                 .setGradientMinpointWithValue(
                     '#FF0000',
                     SpreadsheetApp.InterpolationType.NUMBER,
                     '0',
                     )
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
colorString設定する最小値の色。
typeInterpolationType設定する最小ポイント補間タイプ。
valueString設定する minpoint 値。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setItalic(italic)

条件付き書式設定ルールの書式でテキストを斜体に設定します。italictrue の場合、条件が満たされるとテキストが斜体になります。false の場合、条件が満たされると既存の斜体が削除されます。null を渡すと、ルールから斜体形式の設定が削除されます。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn their text italic if the cell has text equal to "hello".

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenTextEqualTo('hello')
                 .setItalic(true)
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
italicBoolean形式条件が満たされた場合にテキストを斜体にするかどうか。null はこの設定を削除します。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setRanges(ranges)

この条件付き書式ルールが適用される範囲を 1 つ以上設定します。このオペレーションは、既存の範囲を置き換えます。空の配列を設定すると、既存の範囲がすべてクリアされます。ルールには少なくとも 1 つの範囲が必要です。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3
// and range D4:F6 to turn red if they contain a number between 1 and 10.
const sheet = SpreadsheetApp.getActiveSheet();
const rangeOne = sheet.getRange('A1:B3');
const rangeTwo = sheet.getRange('D4:F6');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenNumberBetween(1, 10)
                 .setBackground('#FF0000')
                 .setRanges([rangeOne, rangeTwo])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
rangesRange[]この条件付き書式ルールが適用される範囲。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setStrikethrough(strikethrough)

条件付き書式設定ルールの書式にテキストの取り消し線を設定します。strikethroughtrue の場合、条件が満たされると、ルールによってテキストに取り消し線が引かれます。false の場合、条件が満たされると、ルールによって既存の取り消し線形式が削除されます。null を渡すと、ルールから取り消し線形式の設定が削除されます。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// strikethrough their text if the cell has text equal to "hello".

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenTextEqualTo('hello')
                 .setStrikethrough(true)
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
strikethroughBoolean書式条件が満たされた場合にテキストに取り消し線を引くかどうか。null はこの設定を削除します。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


setUnderline(underline)

条件付き書式設定ルールの書式にテキストの下線を設定します。underlinetrue の場合、条件が満たされるとテキストに下線が引かれます。false の場合、条件が満たされると既存の下線が削除されます。null を渡すと、ルールから下線形式の設定が削除されます。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// underline their text if the cell has text equal to "hello".

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenTextEqualTo('hello')
                 .setUnderline(true)
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
underlineBoolean形式条件が満たされた場合にテキストに下線を引くかどうか。null はこの設定を削除します。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenCellEmpty()

セルが空の場合にトリガーされる条件付き書式設定ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they are empty.
const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenCellEmpty()
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenCellNotEmpty()

セルが空でない場合にトリガーされる条件付き書式設定ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they are not empty.
const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenCellNotEmpty()
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenDateAfter(date)

日付が指定された値より後の場合にトリガーされる条件付き書式ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they contain a date after 11/4/1993.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenDateAfter(new Date('11/4/1993'))
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
dateDate最新の日付。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenDateAfter(date)

指定された相対日付より後の日付になったときに条件付き書式ルールがトリガーされるように設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they contain a date after today.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenDateAfter(SpreadsheetApp.RelativeDate.TODAY)
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
dateRelativeDate選択した日付タイプを基準とした最新の日付。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenDateBefore(date)

日付が指定された日付より前の場合にトリガーされる条件付き書式ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they contain a date before 11/4/1993.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenDateBefore(new Date('11/4/1993'))
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
dateDate受け入れられない最も早い日付。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenDateBefore(date)

日付が指定された相対日付より前の場合にトリガーされる条件付き書式ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they contain a date before today.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenDateBefore(SpreadsheetApp.RelativeDate.TODAY)
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
dateRelativeDate選択した日付タイプを基準とした最新の日付。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenDateEqualTo(date)

日付が指定された日付と等しい場合にトリガーされる条件付き書式設定ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they contain the date 11/4/1993.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenDateEqualTo(new Date('11/4/1993'))
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
dateDate唯一の有効な日付。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenDateEqualTo(date)

日付が指定された相対日付と等しい場合にトリガーされる条件付き書式ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they contain todays date.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenDateEqualTo(SpreadsheetApp.RelativeDate.TODAY)
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
dateRelativeDate選択した日付タイプを基準とした最新の日付。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenFormulaSatisfied(formula)

指定された数式が true と評価されたときにトリガーされる条件付き書式設定ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they satisfy the condition "=EQ(B4, C3)".

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenFormulaSatisfied('=EQ(B4, C3)')
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
formulaString入力が有効な場合に true と評価されるカスタム数式。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenNumberBetween(start, end)

2 つの指定された値の間に数値が収まるか、いずれかの値に等しい場合にトリガーされる条件付き書式ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they contain a number between 1 and 10.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenNumberBetween(1, 10)
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
startNumber許容できる最小値。
endNumber許容される最大値。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenNumberEqualTo(number)

数値が指定された値と等しい場合にトリガーされる条件付き書式ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they contain the number 10.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenNumberEqualTo(10)
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
numberNumber許容される唯一の値。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenNumberGreaterThan(number)

数値が指定された値より大きい場合にトリガーされる条件付き書式ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they contain a number greater than 10.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenNumberGreaterThan(10)
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
numberNumber許容できない最大値。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenNumberGreaterThanOrEqualTo(number)

数値が指定された値以上の場合にトリガーされる条件付き書式ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they contain a number greater than or equal to 10.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenNumberGreaterThanOrEqualTo(10)
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
numberNumber許容できる最小値。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenNumberLessThan(number)

指定された値より小さい数値の場合にトリガーされる条件付き書式設定ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they contain a number less than 10.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenNumberLessThan(10)
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
numberNumber許容できない最小値。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenNumberLessThanOrEqualTo(number)

指定された値以下の数値の場合にトリガーされる条件付き書式ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they contain a number less than or equal to 10.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenNumberLessThanOrEqualTo(10)
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
numberNumber許容される最大値。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenNumberNotBetween(start, end)

2 つの指定された値の間に数値が収まらず、どちらの値でもない場合にトリガーされる条件付き書式ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they contain a number not between 1 and 10.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenNumberNotBetween(1, 10)
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
startNumber許容できない最小値。
endNumber許容できない最大値。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenNumberNotEqualTo(number)

数値が指定された値と等しくない場合にトリガーされる条件付き書式ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they don't contain the number 10.

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenNumberNotEqualTo(10)
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
numberNumber唯一の許容できない値。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenTextContains(text)

入力に指定された値が含まれている場合にトリガーされる条件付き書式ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they contain the text "hello".

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenTextContains('hello')
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
textString入力に含める必要がある値。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenTextDoesNotContain(text)

入力に指定された値が含まれていない場合にトリガーされる条件付き書式ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they don't contain the text "hello".

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenTextDoesNotContain('hello')
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
textString入力に含めてはならない値。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenTextEndsWith(text)

入力が指定された値で終わるときにトリガーされる条件付き書式ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they end with the text "hello".

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenTextEndsWith('hello')
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
textString文字列の末尾と比較するテキスト。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenTextEqualTo(text)

入力が指定された値と等しい場合にトリガーされる条件付き書式ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they have text equal to "hello".

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenTextEqualTo('hello')
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
textString許容される唯一の値。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


whenTextStartsWith(text)

入力が指定された値で始まる場合にトリガーされる条件付き書式ルールを設定します。

// Adds a conditional format rule to a sheet that causes cells in range A1:B3 to
// turn red if they start with the text "hello".

const sheet = SpreadsheetApp.getActiveSheet();
const range = sheet.getRange('A1:B3');
const rule = SpreadsheetApp.newConditionalFormatRule()
                 .whenTextStartsWith('hello')
                 .setBackground('#FF0000')
                 .setRanges([range])
                 .build();
const rules = sheet.getConditionalFormatRules();
rules.push(rule);
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
textString文字列の先頭と比較するテキスト。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。


withCriteria(criteria, args)

条件付き書式ルールの条件を、BooleanCriteria 値で定義された条件に設定します。通常、既存のルールの criteriaarguments から取得されます。

// Adds a new conditional format rule that is a copy of the first active
// conditional format rule, except it instead sets its cells to have a black
// background color.

const sheet = SpreadsheetApp.getActiveSheet();
const rules = sheet.getConditionalFormatRules();
const booleanCondition = rules[0].getBooleanCondition();
if (booleanCondition != null) {
  const rule = SpreadsheetApp.newConditionalFormatRule()
                   .withCriteria(
                       booleanCondition.getCriteriaType(),
                       booleanCondition.getCriteriaValues(),
                       )
                   .setBackground('#000000')
                   .setRanges(rules[0].getRanges())
                   .build();
  rules.push(rule);
}
sheet.setConditionalFormatRules(rules);

パラメータ

名前説明
criteriaBooleanCriteria条件付き書式の条件のタイプ。
argsObject[]条件タイプに適した引数の配列。引数の数とその型は、上記の対応する when...() メソッドと一致します。

戻る

ConditionalFormatRuleBuilder - チェーン用のビルダー。