Class ConditionalFormatRule | Apps Script | Google for Developers (original) (raw)
Class ConditionalFormatRule
Stay organized with collections Save and categorize content based on your preferences.
Detailed documentation
copy()
getBooleanCondition()
Retrieves the rule's [BooleanCondition](/apps-script/reference/spreadsheet/boolean-condition)
information if this rule uses boolean condition criteria. Otherwise returns 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()); }
Return
[BooleanCondition](/apps-script/reference/spreadsheet/boolean-condition)
— the boolean condition object, or null
if the rule does not use a boolean condition.
getGradientCondition()
Retrieves the rule's [GradientCondition](/apps-script/reference/spreadsheet/gradient-condition)
information, if this rule uses gradient condition criteria. Otherwise returns 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()); }
Return
[GradientCondition](/apps-script/reference/spreadsheet/gradient-condition)
— The gradient condition object, or null
if the rule does not use a gradient condition.
getRanges()
Retrieves the ranges to which this conditional format rule is applied.
// 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()); }
Return
[Range[]](/apps-script/reference/spreadsheet/range)
— the ranges to which this conditional format rule is applied.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-12-03 UTC.