[]
        
(Showing Draft Content)

IColorScaleCriterion

Interface IColorScaleCriterion


public interface IColorScaleCriterion
Represents the criteria for the minimum, midpoint, or maximum thresholds for a color scale conditional format.

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());
 
  • Method Summary

    Modifier and Type
    Method
    Description
    Gets a IFormatColor object that specifies the color assigned to the threshold of a color scale conditional format.
    int
    Gets an integer value that indicates which threshold the criterion represents.
    Returns one of the constants of the ConditionValueTypes enumeration, which specifies how the threshold values for a data bar or color scale conditional format are determined.
    Gets the minimum, midpoint, or maximum threshold value for a color scale conditional format.
    void
    Sets one of the constants of the ConditionValueTypes enumeration, which specifies how the threshold values for a data bar or color scale conditional format are determined.
    void
    Sets the minimum, midpoint, or maximum threshold value for a color scale conditional format.
  • Method Details

    • getFormatColor

      IFormatColor getFormatColor()
      Gets a IFormatColor 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));
       
      Returns:
      The IFormatColor object that defines the color for this threshold.
    • getIndex

      int getIndex()
      Gets an integer value that indicates which threshold the criterion represents.

      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();
       
      Returns:
      An integer value that indicates which threshold the criterion represents.
    • getType

      Returns one of the constants of the 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();
       
      Returns:
      One of the constants of the ConditionValueTypes enumeration that indicates how the threshold value for the color scale criterion is determined.
    • setType

      void setType(ConditionValueTypes value)
      Sets one of the constants of the 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);
       
      Parameters:
      value - A ConditionValueTypes constant that specifies how the threshold value is determined.
    • getValue

      Object getValue()
      Gets the minimum, midpoint, or maximum threshold value for a color scale conditional format.

      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();
       
      Returns:
      The threshold value for the criterion. Returns a numeric value for number-, percent-, and percentile-based thresholds, or a String for formula-based thresholds.
    • setValue

      void setValue(Object value)
      Sets the minimum, midpoint, or maximum threshold value for a color scale conditional format.

      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);
       
      Parameters:
      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.