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.
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberBetween(1, 10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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조건부 서식 규칙을 BooleanCriteria 값으로 정의된 기준으로 설정합니다. 이 기준은 일반적으로 기존 규칙의 criteriaarguments에서 가져옵니다.

자세한 문서

build()

작성 도구에 적용된 설정에서 조건부 서식 규칙을 작성합니다.

리턴

ConditionalFormatRule - 조건부 서식 규칙의 표현


copy()

이 규칙의 설정으로 규칙 작성 도구 사전 설정을 반환합니다.

리턴

ConditionalFormatRuleBuilder — 이 규칙의 설정을 기반으로 하는 빌더


getBooleanCondition()

이 규칙이 불리언 조건 기준을 사용하는 경우 규칙의 BooleanCondition 정보를 검색합니다. 그렇지 않으면 null을 반환합니다.

// Log the boolean criteria type of the first conditional format rules of a sheet.
var rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];
var 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.
var rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];
var 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.
var rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];
var ranges = rule.getRanges();
for (var 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".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEqualTo("hello")
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var color = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND)
    .build();
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEqualTo("hello")
    .setBackground(color)
    .setRanges([range])
    .build();
var 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".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEqualTo("hello")
    .setBold(true)
    .setRanges([range])
    .build();
var 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".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEqualTo("hello")
    .setFontColor("#FF0000")
    .setRanges([range])
    .build();
var 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".

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

매개변수

이름유형설명
colorColor원하는 색상 객체 또는 삭제할 null입니다.

리턴

ConditionalFormatRuleBuilder - 체이닝을 위한 빌더입니다.


setGradientMaxpoint(color)

조건부 서식 규칙의 기울기 최댓값 값을 지우고 규칙 범위의 최댓값을 대신 사용합니다. 또한 그라데이션의 maxpoint 색상을 입력 색상으로 설정합니다.

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

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

매개변수

이름유형설명
colorString설정할 최댓값 색상입니다.

리턴

ConditionalFormatRuleBuilder: 체이닝을 위한 빌더입니다.


setGradientMaxpointObject(color)

조건부 서식 규칙의 기울기 최댓값 값을 지우고 규칙 범위의 최댓값을 대신 사용합니다. 또한 그라데이션의 maxpoint 색상을 입력 색상으로 설정합니다.

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

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

매개변수

이름유형설명
colorColor설정할 maxpoint 색상 객체입니다.

리턴

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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var color1 = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1)
    .build();
var color2 = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2)
    .build();
var color3 = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3)
    .build();
var rule = SpreadsheetApp.newConditionalFormatRule()
    .setGradientMaxpointWithValue(color1, SpreadsheetApp.InterpolationType.NUMBER, "100")
    .setGradientMidpointWithValue(color2, SpreadsheetApp.InterpolationType.NUMBER, "50")
    .setGradientMinpointWithValue(color3, SpreadsheetApp.InterpolationType.NUMBER, "0")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .setGradientMaxpointWithValue("#0000FF", SpreadsheetApp.InterpolationType.NUMBER, "100")
    .setGradientMidpointWithValue("#00FF00", SpreadsheetApp.InterpolationType.NUMBER, "50")
    .setGradientMinpointWithValue("#FF0000", SpreadsheetApp.InterpolationType.NUMBER, "0")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var color1 = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT1)
    .build();
var color2 = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT2)
    .build();
var color3 = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.ACCENT3)
    .build();
var rule = SpreadsheetApp.newConditionalFormatRule()
    .setGradientMaxpointWithValue(color1, SpreadsheetApp.InterpolationType.NUMBER, "100")
    .setGradientMidpointWithValue(color2, SpreadsheetApp.InterpolationType.NUMBER, "50")
    .setGradientMinpointWithValue(color3, SpreadsheetApp.InterpolationType.NUMBER, "0")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .setGradientMaxpointWithValue("#0000FF", SpreadsheetApp.InterpolationType.NUMBER, "100")
    .setGradientMidpointWithValue("#00FF00", SpreadsheetApp.InterpolationType.NUMBER, "50")
    .setGradientMinpointWithValue("#FF0000", SpreadsheetApp.InterpolationType.NUMBER, "0")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .setGradientMaxpoint("#FF0000")
    .setGradientMinpoint("#FFFFFF")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var textColor = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.TEXT)
    .build();
var backgroundColor = SpreadsheetApp.newColor()
    .setThemeColor(SpreadsheetApp.ThemeColorType.BACKGROUND)
    .build();
var rule = SpreadsheetApp.newConditionalFormatRule()
    .setGradientMaxpoint(textColor)
    .setGradientMinpoint(backgroundColor)
    .setRanges([range])
    .build();
var 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.

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

매개변수

이름유형설명
colorColor설정할 최소점 색상입니다.
typeInterpolationType설정할 최소점 보간 유형입니다.
valueString설정할 최소점 값입니다.

리턴

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.

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

매개변수

이름유형설명
colorString설정할 최소점 색상입니다.
typeInterpolationType설정할 최소점 보간 유형입니다.
valueString설정할 최소점 값입니다.

리턴

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".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEqualTo("hello")
    .setItalic(true)
    .setRanges([range])
    .build();
var 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.
var sheet = SpreadsheetApp.getActiveSheet();
var rangeOne = sheet.getRange("A1:B3");
var rangeTwo = sheet.getRange("D4:F6");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberBetween(1, 10)
    .setBackground("#FF0000")
    .setRanges([rangeOne, rangeTwo])
    .build();
var 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".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEqualTo("hello")
    .setStrikethrough(true)
    .setRanges([range])
    .build();
var 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".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEqualTo("hello")
    .setUnderline(true)
    .setRanges([range])
    .build();
var 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.
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenCellEmpty()
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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.
var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenCellNotEmpty()
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenDateAfter(new Date("11/4/1993"))
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenDateAfter(SpreadsheetApp.RelativeDate.TODAY)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenDateBefore(new Date("11/4/1993"))
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenDateBefore(SpreadsheetApp.RelativeDate.TODAY)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenDateEqualTo(new Date("11/4/1993"))
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenDateEqualTo(SpreadsheetApp.RelativeDate.TODAY)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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)".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenFormulaSatisfied("=EQ(B4, C3)")
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberBetween(1, 10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberEqualTo(10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberGreaterThan(10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberGreaterThanOrEqualTo(10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberLessThan(10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberLessThanOrEqualTo(10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberNotBetween(1, 10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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.

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenNumberNotEqualTo(10)
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextContains("hello")
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextDoesNotContain("hello")
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEndsWith("hello")
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextEqualTo("hello")
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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".

var sheet = SpreadsheetApp.getActiveSheet();
var range = sheet.getRange("A1:B3");
var rule = SpreadsheetApp.newConditionalFormatRule()
    .whenTextStartsWith("hello")
    .setBackground("#FF0000")
    .setRanges([range])
    .build();
var 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.

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

매개변수

이름유형설명
criteriaBooleanCriteria조건부 서식 기준의 유형입니다.
argsObject[]기준 유형에 적합한 인수 배열입니다. 인수의 수와 유형은 위의 상응하는 when...() 메서드와 일치합니다.

리턴

ConditionalFormatRuleBuilder: 체이닝을 위한 빌더입니다.