Class ConditionalFormatRule
تنظيم صفحاتك في مجموعات
يمكنك حفظ المحتوى وتصنيفه حسب إعداداتك المفضّلة.
مستندات مفصّلة
copy()
تعرض هذه الطريقة إعدادًا مُسبقًا لأداة إنشاء القواعد يتضمّن إعدادات هذه القاعدة.
الإرجاع
ConditionalFormatRuleBuilder
: أداة إنشاء تستند إلى إعدادات هذه القاعدة.
getBooleanCondition()
يسترد معلومات BooleanCondition
الخاصة بالقاعدة إذا كانت هذه القاعدة تستخدم معايير شرطية منطقية. بخلاف ذلك، تعرض null
.
// Log the boolean criteria type of the first conditional format rules of a
// sheet.
const rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];
const booleanCondition = rule.getBooleanCondition();
if (booleanCondition != null) {
Logger.log(booleanCondition.getCriteriaType());
}
الإرجاع
BooleanCondition
: عنصر الشرط المنطقي، أو null
إذا كانت القاعدة لا تستخدم شرطًا منطقيًا.
getGradientCondition()
تعرض هذه السمة معلومات GradientCondition
الخاصة بالقاعدة، إذا كانت هذه القاعدة تستخدم معايير شرط التدرّج. بخلاف ذلك، تعرض null
.
// Log the gradient minimum color of the first conditional format rule of a
// sheet.
const rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];
const gradientCondition = rule.getGradientCondition();
if (gradientCondition != null) {
// Assume the color has ColorType.RGB.
Logger.log(gradientCondition.getMinColorObject().asRgbColor().asHexString());
}
الإرجاع
GradientCondition
: عنصر شرط التدرّج أو null
إذا كانت القاعدة لا تستخدم شرط التدرّج
getRanges()
تعرض هذه الدالة النطاقات التي يتم تطبيق قاعدة التنسيق الشرطي عليها.
// Log each range of the first conditional format rule of a sheet.
const rule = SpreadsheetApp.getActiveSheet().getConditionalFormatRules()[0];
const ranges = rule.getRanges();
for (let i = 0; i < ranges.length; i++) {
Logger.log(ranges[i].getA1Notation());
}
الإرجاع
Range[]
: النطاقات التي يتم تطبيق قاعدة التنسيق الشرطي هذه عليها
إنّ محتوى هذه الصفحة مرخّص بموجب ترخيص Creative Commons Attribution 4.0 ما لم يُنصّ على خلاف ذلك، ونماذج الرموز مرخّصة بموجب ترخيص Apache 2.0. للاطّلاع على التفاصيل، يُرجى مراجعة سياسات موقع Google Developers. إنّ Java هي علامة تجارية مسجَّلة لشركة Oracle و/أو شركائها التابعين.
تاريخ التعديل الأخير: 2025-08-05 (حسب التوقيت العالمي المتفَّق عليه)
[null,null,["تاريخ التعديل الأخير: 2025-08-05 (حسب التوقيت العالمي المتفَّق عليه)"],[[["\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."]]