Class ConditionalFormatRule
컬렉션을 사용해 정리하기
내 환경설정을 기준으로 콘텐츠를 저장하고 분류하세요.
자세한 문서
getBooleanCondition()
이 규칙이 불리언 조건 기준을 사용하는 경우 규칙의 BooleanCondition
정보를 가져옵니다. 그 외에는 null
을 반환합니다.
// Log the boolean criteria type of the first conditional format rules of a
// sheet.
const rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];
const booleanCondition = rule.getBooleanCondition();
if (booleanCondition != null) {
Logger.log(booleanCondition.getCriteriaType());
}
리턴
BooleanCondition
- 불리언 조건 객체입니다. 규칙에서 불리언 조건을 사용하지 않는 경우 null
입니다.
getGradientCondition()
이 규칙이 그라데이션 조건 기준을 사용하는 경우 규칙의 GradientCondition
정보를 가져옵니다. 그 외에는 null
을 반환합니다.
// Log the gradient minimum color of the first conditional format rule of a
// sheet.
const rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];
const gradientCondition = rule.getGradientCondition();
if (gradientCondition != null) {
// Assume the color has ColorType.RGB.
Logger.log(gradientCondition.getMinColorObject().asRgbColor().asHexString());
}
리턴
GradientCondition
- 그라데이션 조건 객체입니다. 규칙에서 그라데이션 조건을 사용하지 않는 경우 null
입니다.
getRanges()
이 조건부 서식 규칙이 적용되는 범위를 가져옵니다.
// Log each range of the first conditional format rule of a sheet.
const rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];
const ranges = rule.getRanges();
for (let i = 0; i < ranges.length; i++) {
Logger.log(ranges[i].getA1Notation());
}
리턴
Range[]
- 이 조건부 서식 규칙이 적용되는 범위입니다.
달리 명시되지 않는 한 이 페이지의 콘텐츠에는 Creative Commons Attribution 4.0 라이선스에 따라 라이선스가 부여되며, 코드 샘플에는 Apache 2.0 라이선스에 따라 라이선스가 부여됩니다. 자세한 내용은 Google Developers 사이트 정책을 참조하세요. 자바는 Oracle 및/또는 Oracle 계열사의 등록 상표입니다.
최종 업데이트: 2025-08-05(UTC)
[null,null,["최종 업데이트: 2025-08-05(UTC)"],[[["\u003cp\u003e\u003ccode\u003eXFrameOptionsMode\u003c/code\u003e is used to control how a client-side Apps Script HTML Service output can be embedded in iframes on other websites.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eALLOWALL\u003c/code\u003e permits any site to embed the page, demanding developer-implemented clickjacking protection, while \u003ccode\u003eDEFAULT\u003c/code\u003e maintains standard security with no \u003ccode\u003eX-Frame-Options\u003c/code\u003e header.\u003c/p\u003e\n"],["\u003cp\u003eIf a script doesn't explicitly set a mode, Apps Script defaults to \u003ccode\u003eDEFAULT\u003c/code\u003e, ensuring standard security behaviors are in effect.\u003c/p\u003e\n"]]],["Conditional format rules can be accessed and managed using the provided methods. New rules are created via `SpreadsheetApp.newConditionalFormatRule()`. Existing rules can be copied with `copy()`, retrieving a builder with the same settings. The `getBooleanCondition()` and `getGradientCondition()` methods fetch information based on the rule's criteria, while `getRanges()` retrieves the ranges the rule applies to. `Sheet.setConditionalFormatRules(rules)` applies rule settings to a given sheet.\n"],null,["# Class ConditionalFormatRule\n\nConditionalFormatRule\n\nAccess conditional formatting rules. To create a new rule, use [SpreadsheetApp.newConditionalFormatRule()](/apps-script/reference/spreadsheet/spreadsheet-app#newConditionalFormatRule()) and [ConditionalFormatRuleBuilder](/apps-script/reference/spreadsheet/conditional-format-rule-builder).\nYou can use [Sheet.setConditionalFormatRules(rules)](/apps-script/reference/spreadsheet/sheet#setConditionalFormatRules(ConditionalFormatRule)) to set the\nrules for a given sheet. \n\n### Methods\n\n| Method | Return type | Brief description |\n|---------------------------------------------------|----------------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [copy()](#copy()) | [ConditionalFormatRuleBuilder](/apps-script/reference/spreadsheet/conditional-format-rule-builder) | Returns a rule builder preset with this rule's settings. |\n| [getBooleanCondition()](#getBooleanCondition()) | [BooleanCondition](/apps-script/reference/spreadsheet/boolean-condition) | Retrieves the rule's [BooleanCondition](/apps-script/reference/spreadsheet/boolean-condition) information if this rule uses boolean condition criteria. |\n| [getGradientCondition()](#getGradientCondition()) | [GradientCondition](/apps-script/reference/spreadsheet/gradient-condition) | Retrieves the rule's [GradientCondition](/apps-script/reference/spreadsheet/gradient-condition) information, if this rule uses gradient condition criteria. |\n| [getRanges()](#getRanges()) | [Range[]](/apps-script/reference/spreadsheet/range) | Retrieves the ranges to which this conditional format rule is applied. |\n\nDetailed documentation\n----------------------\n\n### `copy()`\n\nReturns a rule builder preset with this rule's settings.\n\n#### Return\n\n\n[ConditionalFormatRuleBuilder](/apps-script/reference/spreadsheet/conditional-format-rule-builder) --- A builder based on this rule's settings.\n\n*** ** * ** ***\n\n### `get``Boolean``Condition()`\n\nRetrieves the rule's [BooleanCondition](/apps-script/reference/spreadsheet/boolean-condition) information if this rule uses\nboolean condition criteria. Otherwise returns `null`.\n\n```javascript\n// Log the boolean criteria type of the first conditional format rules of a\n// sheet.\nconst rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];\nconst booleanCondition = rule.getBooleanCondition();\nif (booleanCondition != null) {\n Logger.log(booleanCondition.getCriteriaType());\n}\n```\n\n#### Return\n\n\n[BooleanCondition](/apps-script/reference/spreadsheet/boolean-condition) --- The boolean condition object, or `null` if the rule does not use a boolean\ncondition.\n\n*** ** * ** ***\n\n### `get``Gradient``Condition()`\n\nRetrieves the rule's [GradientCondition](/apps-script/reference/spreadsheet/gradient-condition) information, if this rule\nuses gradient condition criteria. Otherwise returns `null`.\n\n```javascript\n// Log the gradient minimum color of the first conditional format rule of a\n// sheet.\nconst rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];\nconst gradientCondition = rule.getGradientCondition();\nif (gradientCondition != null) {\n // Assume the color has ColorType.RGB.\n Logger.log(gradientCondition.getMinColorObject().asRgbColor().asHexString());\n}\n```\n\n#### Return\n\n\n[GradientCondition](/apps-script/reference/spreadsheet/gradient-condition) --- The gradient condition object, or `null` if the rule does not use a gradient\ncondition.\n\n*** ** * ** ***\n\n### `get``Ranges()`\n\nRetrieves the ranges to which this conditional format rule is applied.\n\n```javascript\n// Log each range of the first conditional format rule of a sheet.\nconst rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];\nconst ranges = rule.getRanges();\nfor (let i = 0; i \u003c ranges.length; i++) {\n Logger.log(ranges[i].getA1Notation());\n}\n```\n\n#### Return\n\n\n[Range[]](/apps-script/reference/spreadsheet/range) --- The ranges to which this conditional format rule is applied."]]