Class GradientCondition

GradientCondition

Access gradient (color) conditions in ConditionalFormatRuleApis. Each conditional format rule may contain a single gradient condition. A gradient condition is defined by three points along a number scale (min, mid, and max), each of which has a color, a value, and a InterpolationType. The content of a cell is compared to the values in the number scale and the color applied to the cell is interpolated based 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.
var sheet = SpreadsheetApp.getActiveSheet();
var rules = sheet.getConditionalFormatRules();
for (int i = 0; i < rules.length; i++) {
  var gradient = rules[i].getGradientCondition();
  Logger.log("The conditional format gradient information for rule %d:\n
    MinColor %s, MinType %s, MinValue %s, \n
    MidColor %s, MidType %s, MidValue %s, \n
    MaxColor %s, MaxType %s, MaxValue %s \n", i,
    gradient.getMinColorObject().asRgbColor().asHexString(),
    gradient.getMinType(), gradient.getMinValue(),
    gradient.getMidColorObject().asRgbColor().asHexString(),
    gradient.getMidType(), gradient.getMidValue(),
    gradient.getMaxColorObject().asRgbColor().asHexString(),
    gradient.getMaxType(), gradient.getMaxValue());
}

Methods

MethodReturn typeBrief description
getMaxColorObject()ColorGets the color set for the maximum value of this gradient condition.
getMaxType()InterpolationTypeGets the interpolation type for the maximum value of this gradient condition.
getMaxValue()StringGets the max value of this gradient condition.
getMidColorObject()ColorGets the color set for the midpoint value of this gradient condition.
getMidType()InterpolationTypeGets the interpolation type for the mid-point value of this gradient condition.
getMidValue()StringGets the mid-point value of this gradient condition.
getMinColorObject()ColorGets the color set for the minimum value of this gradient condition.
getMinType()InterpolationTypeGets the interpolation type for the minimum value of this gradient condition.
getMinValue()StringGets the minimum value of this gradient condition.

Detailed documentation

getMaxColorObject()

Gets the color set for the maximum value of this gradient condition. Returns null if the color hasn't been set.

Return

Color — The color set for the maximum value of this gradient condition or null.


getMaxType()

Gets the interpolation type for the maximum value of this gradient condition. Returns null if the gradient max type hasn't been set.

Return

InterpolationType — the interpolation type for the maximum value of this gradient condition or null


getMaxValue()

Gets the max value of this gradient condition. Returns an empty string if the InterpolationType is MAX or if the max value hasn't been set.

Return

String — the maximum value if specified or an empty string


getMidColorObject()

Gets the color set for the midpoint value of this gradient condition. Returns null if the color hasn't been set.

Return

Color — The color set for the midpoint value of this gradient condition or null.


getMidType()

Gets the interpolation type for the mid-point value of this gradient condition. Returns null if the gradient mid type hasn't been set.

Return

InterpolationType — the interpolation type for the mid-point value of this gradient condition or null


getMidValue()

Gets the mid-point value of this gradient condition. Returns an empty string if the gradient mid value hasn't been set.

Return

String — the mid-point value or an empty string


getMinColorObject()

Gets the color set for the minimum value of this gradient condition. Returns null if the color hasn't been set.

Return

Color — The color set for the minimum value of this gradient condition or null.


getMinType()

Gets the interpolation type for the minimum value of this gradient condition. Returns null if the gradient min type hasn't been set.

Return

InterpolationType — the interpolation type for the minimum value of this gradient condition or null


getMinValue()

Gets the minimum value of this gradient condition. Returns an empty string if the InterpolationType is MIN or if the min value hasn't been set.

Return

String — the minimum value if specified or an empty string

Deprecated methods