Class GradientCondition Stay organized with collections Save and categorize content based on your preferences.
Page Summary
GradientCondition is used to access gradient color conditions in ConditionalFormatRuleApis.
A gradient condition is defined by three points (min, mid, max), each with a color, value, and InterpolationType.
Cell colors are interpolated based on their content's proximity to the min, mid, and max points of the gradient condition.
Methods are available to get the color object, interpolation type, and value for the min, mid, and max points.
Some methods for getting color as a string are deprecated and replaced by methods returning Color objects.
Access gradient (color) conditions inConditional.Each conditional format rule may contain a single gradient condition. A gradient condition isdefined by three points along a number scale (min, mid, and max), each of which has a color, avalue, and aInterpolation. The content of a cell iscompared to the values in the number scale and the color applied to the cell is interpolatedbased on the cell content's proximity to the gradient condition min, mid, and max points.
// Logs all the information inside gradient conditional format rules on a sheet.// The below snippet assumes all colors have ColorType.RGB.constsheet=SpreadsheetApp.getActiveSheet();construles=sheet.getConditionalFormatRules();for(leti=0;i <rules.length;i++){constgradient=rules[i].getGradientCondition();constminColor=gradient.getMinColorObject().asRgbColor().asHexString();constminType=gradient.getMinType();constminValue=gradient.getMinValue();constmidColor=gradient.getMidColorObject().asRgbColor().asHexString();constmidType=gradient.getMidType();constmidValue=gradient.getMidValue();constmaxColor=gradient.getMaxColorObject().asRgbColor().asHexString();constmaxType=gradient.getMaxType();constmaxValue=gradient.getMaxValue();Logger.log(`The conditional format gradient information for rule${i}: MinColor${minColor}, MinType${minType}, MinValue${minValue}, MidColor${midColor}, MidType${midType}, MidValue${midValue}, MaxColor${maxColor}, MaxType${maxType}, MaxValue${maxValue}`);}
Methods
| Method | Return type | Brief description |
|---|---|---|
get | Color|null | Gets the color set for the maximum value of this gradient condition. |
get | Interpolation | Gets the interpolation type for the maximum value of this gradient condition. |
get | String | Gets the max value of this gradient condition. |
get | Color|null | Gets the color set for the midpoint value of this gradient condition. |
get | Interpolation | Gets the interpolation type for the midpoint value of this gradient condition. |
get | String | Gets the midpoint value of this gradient condition. |
get | Color|null | Gets the color set for the minimum value of this gradient condition. |
get | Interpolation | Gets the interpolation type for the minimum value of this gradient condition. |
get | String | Gets the minimum value of this gradient condition. |
Deprecated methods
| Method | Return type | Brief description |
|---|---|---|
| String | Gets the color set for the maximum value of this gradient condition. |
| String | Gets the color set for the midpoint value of this gradient condition. |
| String | Gets the color set for the minimum value of this gradient condition. |
Detailed documentation
getMaxColorObject()
Gets the color set for the maximum value of this gradient condition. Returnsnull ifthe color hasn't been set.
Return
Color|null — The color set for the maximum value of this gradient condition ornull.
getMaxType()
Gets the interpolation type for the maximum value of this gradient condition. Returnsnull if the gradient max type hasn't been set.
Return
Interpolation — The interpolation type for the maximum value of this gradient condition ornull.
getMaxValue()
Gets the max value of this gradient condition. Returns an empty string if theInterpolation isMAX or if the max value hasn't beenset.
Return
String — The maximum value if specified or an empty string.
getMidColorObject()
Gets the color set for the midpoint value of this gradient condition. Returnsnull ifthe color hasn't been set.
Return
Color|null — The color set for the midpoint value of this gradient condition ornull.
getMidType()
Gets the interpolation type for the midpoint value of this gradient condition. Returnsnull if the gradient mid type hasn't been set.
Return
Interpolation — The interpolation type for the midpoint value of this gradient condition ornull.
getMidValue()
Gets the midpoint value of this gradient condition. Returns an empty string if the gradient midvalue hasn't been set.
Return
String — The midpoint value or an empty string.
getMinColorObject()
Gets the color set for the minimum value of this gradient condition. Returnsnull ifthe color hasn't been set.
Return
Color|null — The color set for the minimum value of this gradient condition ornull.
getMinType()
Gets the interpolation type for the minimum value of this gradient condition. Returnsnull if the gradient min type hasn't been set.
Return
Interpolation — The interpolation type for the minimum value of this gradient condition ornull.
getMinValue()
Gets the minimum value of this gradient condition. Returns an empty string if theInterpolation isMIN or if the min value hasn't beenset.
Return
String — The minimum value if specified or an empty string.
Deprecated methods
getMaxColor()
getMaxColor() Deprecated. Replaced byget
Gets the color set for the maximum value of this gradient condition. Returns an empty string ifthe color hasn't been set.
Return
String — The color set for the maximum value of this gradient condition or an empty string.
getMidColor()
getMidColor() Deprecated. Replaced byget
Gets the color set for the midpoint value of this gradient condition. Returns an empty stringif the color hasn't been set.
Return
String — The color set for the midpoint value of this gradient condition or an empty string.
getMinColor()
getMinColor() Deprecated. Replaced byget
Gets the color set for the minimum value of this gradient condition. Returns an empty string ifthe color hasn't been set.
Return
String — The color set for the minimum value of this gradient condition or an empty string.
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2025-12-11 UTC.