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이 조건부 서식 규칙이 적용되는 범위를 하나 이상 설정합니다.
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숫자가 두 지정된 값 사이에 있거나 두 값 중 하나일 때 트리거되도록 조건부 서식 규칙을 설정합니다.
whenNumberEqualTo(number)ConditionalFormatRuleBuilder숫자가 지정된 값과 같을 때 트리거되도록 조건부 서식 규칙을 설정합니다.
whenNumberGreaterThan(number)ConditionalFormatRuleBuilder숫자가 지정된 값보다 클 때 트리거되도록 조건부 서식 규칙을 설정합니다.
whenNumberGreaterThanOrEqualTo(number)ConditionalFormatRuleBuilder숫자가 지정된 값보다 크거나 같을 때 트리거되도록 조건부 서식 규칙을 설정합니다.
whenNumberLessThan(number)ConditionalFormatRuleBuilder주어진 값보다 작은 숫자가 있을 때 트리거되도록 조건부 서식 규칙을 설정합니다.
whenNumberLessThanOrEqualTo(number)ConditionalFormatRuleBuilder주어진 값보다 작거나 같은 숫자가 있을 때 트리거되도록 조건부 서식 규칙을 설정합니다.
whenNumberNotBetween(start, end)ConditionalFormatRuleBuilder숫자가 두 지정된 값 사이에 있지 않고 두 값 중 하나도 아닌 경우 트리거되도록 조건부 서식 규칙을 설정합니다.
whenNumberNotEqualTo(number)ConditionalFormatRuleBuilder숫자가 지정된 값과 같지 않을 때 트리거되도록 조건부 서식 규칙을 설정합니다.
whenTextContains(text)ConditionalFormatRuleBuilder입력에 지정된 값이 포함될 때 트리거되도록 조건부 서식 규칙을 설정합니다.
whenTextDoesNotContain(text)ConditionalFormatRuleBuilder입력에 지정된 값이 포함되지 않을 때 트리거되는 조건부 서식 규칙을 설정합니다.
whenTextEndsWith(text)ConditionalFormatRuleBuilder입력이 지정된 값으로 끝날 때 트리거되도록 조건부 서식 규칙을 설정합니다.
whenTextEqualTo(text)ConditionalFormatRuleBuilder입력이 지정된 값과 같을 때 트리거되도록 조건부 서식 규칙을 설정합니다.
whenTextStartsWith(text)ConditionalFormatRuleBuilder입력이 지정된 값으로 시작될 때 트리거되도록 조건부 서식 규칙을 설정합니다.
withCriteria(criteria, args)ConditionalFormatRuleBuilder기존 규칙의 criteriaarguments에서 가져온 BooleanCriteria 값으로 정의된 기준에 따라 조건부 서식 규칙을 설정합니다.

자세한 문서

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설정할 minpoint 보간 유형입니다.
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설정할 minpoint 보간 유형입니다.
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)

이 조건부 서식 규칙이 적용되는 범위를 하나 이상 설정합니다. 이 작업은 기존 범위를 대체합니다. 빈 배열을 설정하면 기존 범위가 삭제됩니다. 규칙에는 범위가 하나 이상 있어야 합니다.

// 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)

숫자가 두 지정된 값 사이에 있거나 두 값 중 하나일 때 트리거되도록 조건부 서식 규칙을 설정합니다.

// 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)

숫자가 두 지정된 값 사이에 있지 않고 두 값 중 하나도 아닌 경우 트리거되도록 조건부 서식 규칙을 설정합니다.

// 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)

기존 규칙의 criteriaarguments에서 가져온 BooleanCriteria 값으로 정의된 기준에 따라 조건부 서식 규칙을 설정합니다.

// 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 - 연결을 위한 빌더입니다.