조건부 서식 규칙 작성 도구
// 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()
copy()
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()); }
Return
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()); }
Return
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()); }
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String | 삭제하려는 색상 또는 null 입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color | 삭제하려는 색상 객체 또는 null 입니다. |
Return
ConditionalFormatRuleBuilder
— 체이닝된 빌더입니다.
setBold(bold)
조건부 서식 규칙의 텍스트 굵게를 설정합니다. bold
이 true
이면 조건이 충족되면 규칙이 텍스트를 굵게 표시합니다. 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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
bold | Boolean | 서식 조건이 충족되었을 때 텍스트를 굵게 표시할지 여부입니다. null 에서 이 설정을 삭제합니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String | 삭제하려는 색상 또는 null 입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color | 삭제하려는 색상 객체 또는 null 입니다. |
Return
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. 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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String | 설정할 최대점 색상입니다. |
Return
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. 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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color | 설정할 maxpoint 색상 객체입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color | 설정할 최대점 색상입니다. |
type | InterpolationType | 설정할 최대 지점 보간 유형입니다. |
value | String | 설정할 최대값입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String | 설정할 최대점 색상입니다. |
type | InterpolationType | 설정할 최대 지점 보간 유형입니다. |
value | String | 설정할 최대값입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color | 설정할 중간점 색상입니다. |
type | InterpolationType | 설정할 중간 보간 유형 또는 지워야 하는 null . |
value | String | 설정할 중간값입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String | 설정할 중간점 색상입니다. |
type | InterpolationType | 설정할 중간 보간 유형 또는 지워야 하는 null . |
value | String | 설정할 중간값입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String | 설정할 최솟값입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color | 설정할 최소점 색상 객체입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color | 설정할 최솟값입니다. |
type | InterpolationType | 설정할 최소점 보간 유형입니다. |
value | String | 설정할 최솟값입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String | 설정할 최솟값입니다. |
type | InterpolationType | 설정할 최소점 보간 유형입니다. |
value | String | 설정할 최솟값입니다. |
Return
ConditionalFormatRuleBuilder
— 체이닝용 빌더
setItalic(italic)
조건부 서식 규칙의 텍스트 기울임꼴을 설정합니다. italic
이 true
인 경우 규칙이 충족되면 규칙이 텍스트 기울임꼴로 표시됩니다. 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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
italic | Boolean | 형식 조건이 충족되면 텍스트를 기울임꼴로 표시해야 하는지를 나타냅니다.
null 는 이 설정을 삭제합니다. |
Return
ConditionalFormatRuleBuilder
— 체이닝용 빌더
setRanges(ranges)
이 조건부 서식 규칙이 적용되는 하나 이상의 범위를 설정합니다. 이 작업은 기존 범위를 대체합니다. 빈 배열을 설정하면 기존 범위가 모두 삭제됩니다. 규칙에는 범위가 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. 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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
ranges | Range[] | 이 조건부 서식 규칙이 적용되는 범위입니다. |
Return
ConditionalFormatRuleBuilder
— 체이닝용 빌더
setStrikethrough(strikethrough)
조건부 서식 규칙의 텍스트 취소선을 설정합니다. strikethrough
이 true
이면 조건이 충족되면 규칙에서 텍스트에 취소선이 표시됩니다. 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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
strikethrough | Boolean | 형식 조건이 충족되었을 때 텍스트를 취소선으로 표시해야 하는지 여부입니다. null 은 이 설정을 삭제합니다. |
Return
ConditionalFormatRuleBuilder
— 체이닝용 빌더
setUnderline(underline)
조건부 서식 규칙의 텍스트 밑줄을 설정합니다. underline
이 true
인 경우 조건이 충족되면 규칙에 텍스트 밑줄이 표시되고 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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
underline | Boolean | 형식 조건이 충족될 때 텍스트에 밑줄을 추가할지 나타냅니다. null 는 이 설정을 삭제합니다. |
Return
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);
Return
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);
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
date | Date | 최근 날짜 |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
date | RelativeDate | 선택한 날짜 유형을 기준으로 한 최근 날짜입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
date | Date | 허용되지 않는 가장 빠른 날짜입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
date | RelativeDate | 선택한 날짜 유형을 기준으로 한 최근 날짜입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
date | Date | 유일하게 허용되는 날짜입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
date | RelativeDate | 선택한 날짜 유형을 기준으로 한 최근 날짜입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
formula | String | 입력이 유효한 경우 true 로 판정하는 맞춤 수식입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
start | Number | 사용 가능한 가장 낮은 값입니다. |
end | Number | 허용되는 최댓값입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
number | Number | 유일하게 사용할 수 있는 값입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
number | Number | 허용되지 않는 최댓값입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
number | Number | 사용 가능한 가장 낮은 값입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
number | Number | 허용되지 않는 최저 값입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
number | Number | 허용되는 최댓값입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
start | Number | 허용되지 않는 최저 값입니다. |
end | Number | 허용되지 않는 최댓값입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
number | Number | 허용되지 않는 유일한 값입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
text | String | 입력에 포함해야 하는 값입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
text | String | 입력에 포함되면 안 되는 값입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
text | String | 문자열의 끝 부분과 비교할 텍스트입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
text | String | 유일하게 사용할 수 있는 값입니다. |
Return
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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
text | String | 문자열의 시작 부분과 비교할 텍스트입니다. |
Return
ConditionalFormatRuleBuilder
— 체이닝용 빌더
withCriteria(criteria, args)
조건부 서식 규칙을 BooleanCriteria
값으로 정의된 기준(일반적으로 기존 규칙의 criteria
및 arguments
에서 가져옴)으로 설정합니다.
// 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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
criteria | BooleanCriteria | 조건부 서식 기준의 유형입니다. |
args | Object[] | 기준 유형에 적합한 인수 배열입니다. 인수의 수와 그 유형은 위의 when...() 메서드와 일치합니다. |
Return
ConditionalFormatRuleBuilder
— 체이닝용 빌더