조건부 서식 규칙 빌더입니다.
// 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()
copy()
get Boolean Condition()
이 규칙이 불리언 조건 기준을 사용하는 경우 규칙의 Boolean
정보를 가져옵니다. 그 외에는 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()); }
리턴
Boolean
- 불리언 조건 객체입니다. 규칙에서 불리언 조건을 사용하지 않는 경우 null
입니다.
get Gradient Condition()
이 규칙이 그라데이션 조건 기준을 사용하는 경우 규칙의 Gradient
정보를 가져옵니다. 그 외에는 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()); }
리턴
Gradient
- 그라데이션 조건 객체입니다. 규칙에서 그라데이션 조건을 사용하지 않는 경우 null
입니다.
get Ranges()
이 조건부 서식 규칙이 적용되는 범위를 가져옵니다.
// 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[]
- 이 조건부 서식 규칙이 적용되는 범위입니다.
set Background(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String | 원하는 색상 또는 null (지우기) |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Background Object(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color | 원하는 색상 객체 또는 null (지우기)입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Bold(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". 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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
bold | Boolean | 서식 조건이 충족될 때 텍스트를 굵게 표시할지 여부입니다. null 는 이 설정을 삭제합니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Font Color(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String | 원하는 색상 또는 null (지우기) |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Font Color Object(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color | 원하는 색상 객체 또는 null (지우기)입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Gradient Maxpoint(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String | 설정할 최댓값 색상입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Gradient Maxpoint Object(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color | 설정할 최댓값 색상 객체입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Gradient Maxpoint Object With Value(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color | 설정할 최댓값 색상입니다. |
type | Interpolation | 설정할 maxpoint 보간 유형입니다. |
value | String | 설정할 maxpoint 값입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Gradient Maxpoint With Value(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String | 설정할 최댓값 색상입니다. |
type | Interpolation | 설정할 maxpoint 보간 유형입니다. |
value | String | 설정할 maxpoint 값입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Gradient Midpoint Object With Value(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color | 설정할 중간점 색상입니다. |
type | Interpolation | 설정할 중간점 보간 유형 또는 삭제할 null 입니다. |
value | String | 설정할 중간점 값입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Gradient Midpoint With Value(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String | 설정할 중간점 색상입니다. |
type | Interpolation | 설정할 중간점 보간 유형 또는 삭제할 null 입니다. |
value | String | 설정할 중간점 값입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Gradient Minpoint(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String | 설정할 최솟값 색상입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Gradient Minpoint Object(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color | 설정할 최소점 색상 객체입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Gradient Minpoint Object With Value(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | Color | 설정할 최솟값 색상입니다. |
type | Interpolation | 설정할 minpoint 보간 유형입니다. |
value | String | 설정할 minpoint 값입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Gradient Minpoint With Value(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
color | String | 설정할 최솟값 색상입니다. |
type | Interpolation | 설정할 minpoint 보간 유형입니다. |
value | String | 설정할 minpoint 값입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Italic(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". 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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
italic | Boolean | 서식 조건이 충족될 때 텍스트를 기울임체로 표시할지 여부입니다.
null 에서는 이 설정이 삭제됩니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Ranges(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
ranges | Range[] | 이 조건부 서식 규칙이 적용되는 범위입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Strikethrough(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". 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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
strikethrough | Boolean | 형식 조건이 충족될 때 텍스트에 취소선을 적용할지 여부입니다. null 에서는 이 설정을 삭제합니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
set Underline(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". 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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
underline | Boolean | 서식 조건이 충족될 때 텍스트에 밑줄을 표시할지 여부입니다.
null 에서는 이 설정을 삭제합니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Cell Empty()
셀이 비어 있을 때 트리거되는 조건부 서식 규칙을 설정합니다.
// 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);
리턴
Conditional
- 연결을 위한 빌더입니다.
when Cell Not Empty()
셀이 비어 있지 않을 때 트리거되도록 조건부 서식 규칙을 설정합니다.
// 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);
리턴
Conditional
- 연결을 위한 빌더입니다.
when Date After(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
date | Date | 최신 날짜입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Date After(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
date | Relative | 선택한 날짜 유형을 기준으로 한 최신 날짜입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Date Before(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
date | Date | 허용되지 않는 가장 빠른 날짜입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Date Before(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
date | Relative | 선택한 날짜 유형을 기준으로 한 최신 날짜입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Date Equal To(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
date | Date | 유일하게 허용되는 날짜입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Date Equal To(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
date | Relative | 선택한 날짜 유형을 기준으로 한 최신 날짜입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Formula Satisfied(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
formula | String | 입력이 유효한 경우 true 로 평가되는 맞춤 수식입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Number Between(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
start | Number | 허용되는 최저 값입니다. |
end | Number | 허용되는 가장 높은 값입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Number Equal To(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
number | Number | 허용되는 유일한 값입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Number Greater Than(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
number | Number | 허용되지 않는 가장 높은 값입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Number Greater Than Or Equal To(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
number | Number | 허용되는 최저 값입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Number Less Than(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
number | Number | 허용되지 않는 가장 낮은 값입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Number Less Than Or Equal To(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
number | Number | 허용되는 가장 높은 값입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Number Not Between(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
start | Number | 허용되지 않는 가장 낮은 값입니다. |
end | Number | 허용되지 않는 가장 높은 값입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Number Not Equal To(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
number | Number | 허용되지 않는 유일한 값입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Text Contains(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
text | String | 입력에 포함되어야 하는 값입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Text Does Not Contain(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
text | String | 입력에 포함되어서는 안 되는 값입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Text Ends With(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
text | String | 문자열의 끝과 비교할 텍스트입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Text Equal To(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
text | String | 허용되는 유일한 값입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
when Text Starts With(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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
text | String | 문자열의 시작 부분과 비교할 텍스트입니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.
with Criteria(criteria, args)
기존 규칙의 criteria
및 arguments
에서 가져온 Boolean
값으로 정의된 기준에 따라 조건부 서식 규칙을 설정합니다.
// 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);
매개변수
이름 | 유형 | 설명 |
---|---|---|
criteria | Boolean | 조건부 서식 기준의 유형입니다. |
args | Object[] | 기준 유형에 적합한 인수 배열입니다. 인수의 수와 유형은 위의 해당 when...() 메서드와 일치합니다. |
리턴
Conditional
- 연결을 위한 빌더입니다.