[]
An IColorScaleCriterion defines one threshold in a color scale rule, including how the threshold value is determined and which color is assigned to that threshold. Use it through IColorScale.getColorScaleCriteria() to inspect or customize the criteria in a two-color or three-color scale.
IColorScale colorScale = worksheet.getRange("A1:A5").getFormatConditions()
.addColorScale(ColorScaleType.ThreeColorScale);
IColorScaleCriterion criterion = colorScale.getColorScaleCriteria().get(1);
criterion.setType(ConditionValueTypes.Percent);
criterion.setValue(50);
criterion.getFormatColor().setColor(Color.GetYellow());
IFormatColor object that specifies the color assigned to the threshold of a color scale conditional format.intgetIndex()getType()ConditionValueTypes enumeration, which specifies how the threshold values for a data bar or color scale conditional format are determined.getValue()voidsetType(ConditionValueTypes value) ConditionValueTypes enumeration, which specifies how the threshold values for a data bar or color scale conditional format are determined.voidIFormatColor object that specifies the color assigned to the threshold of a color scale conditional format. Use the returned object to inspect or modify the color for the minimum, midpoint, or maximum threshold represented by this criterion.
IColorScale colorScale = worksheet.getRange("A1:A5").getFormatConditions()
.addColorScale(ColorScaleType.TwoColorScale);
IColorScaleCriterion criterion = colorScale.getColorScaleCriteria().get(0);
IFormatColor formatColor = criterion.getFormatColor();
formatColor.setColor(Color.FromArgb(255, 0, 0));
IFormatColor object that defines the color for this threshold.Use this method to identify whether the criterion corresponds to the minimum, midpoint, or maximum threshold in a color scale conditional format.
IColorScale colorScale = worksheet.getRange("A1:A5").getFormatConditions()
.addColorScale(ColorScaleType.ThreeColorScale);
IColorScaleCriterion criterion = colorScale.getColorScaleCriteria().get(1);
int index = criterion.getIndex();
ConditionValueTypes enumeration, which specifies how the threshold values for a data bar or color scale conditional format are determined. Use this method to inspect whether the criterion threshold is based on a number, percent, percentile, formula, or an automatic minimum or maximum value.
worksheet.getRange("A1:A5").setValue(new Object[] {10, 30, 50, 70, 90});
IColorScale colorScale = worksheet.getRange("A1:A5")
.getFormatConditions().addColorScale(ColorScaleType.ThreeColorScale);
IColorScaleCriterion criterion = colorScale.getColorScaleCriteria().get(1);
criterion.setType(ConditionValueTypes.Percent);
ConditionValueTypes type = criterion.getType();
ConditionValueTypes enumeration that indicates how the threshold value for the color scale criterion is determined.ConditionValueTypes enumeration, which specifies how the threshold values for a data bar or color scale conditional format are determined. Use this method to define whether the criterion threshold is based on an absolute number, percentage, percentile, formula, or automatic minimum or maximum value. When the type requires an explicit threshold, set the threshold with setValue(Object).
worksheet.getRange("A1:A5").setValue(new Object[] {10, 30, 50, 70, 90});
IColorScale colorScale = worksheet.getRange("A1:A5")
.getFormatConditions().addColorScale(ColorScaleType.ThreeColorScale);
IColorScaleCriterion criterion = colorScale.getColorScaleCriteria().get(1);
criterion.setType(ConditionValueTypes.Percent);
criterion.setValue(50);
value - A ConditionValueTypes constant that specifies how the threshold value is determined.You can set the value only if the criterion type is set by setType(ConditionValueTypes) to ConditionValueTypes.Number, ConditionValueTypes.Percent, ConditionValueTypes.Percentile, or ConditionValueTypes.Formula. If the threshold type is a formula, the value must be set as a String. The formula must return a single number.
IColorScale colorScale = worksheet.getRange("A1:A5").getFormatConditions()
.addColorScale(ColorScaleType.TwoColorScale);
IColorScaleCriterion criterion = colorScale.getColorScaleCriteria().get(0);
criterion.setType(ConditionValueTypes.Number);
criterion.setValue(10);
Object value = criterion.getValue();
String for formula-based thresholds.You can set the value only if the criterion type is set by setType(ConditionValueTypes) to ConditionValueTypes.Number, ConditionValueTypes.Percent, ConditionValueTypes.Percentile, or ConditionValueTypes.Formula. If the threshold type is a formula, the value is returned as a String. The formula must return a single number.
IColorScale colorScale = worksheet.getRange("A1:A5").getFormatConditions()
.addColorScale(ColorScaleType.TwoColorScale);
IColorScaleCriterion criterion = colorScale.getColorScaleCriteria().get(0);
criterion.setType(ConditionValueTypes.Number);
criterion.setValue(10);
value - The threshold value for the criterion. Sets a numeric value for number-, percent-, and percentile-based thresholds, or a String for formula-based thresholds.