[]
        
首页
开发者学堂
文档
论坛
市场
生态机会
活动
立即试用
(Showing Draft Content)

IColorScaleCriterion

Interface IColorScaleCriterion


public interface IColorScaleCriterion
表示颜色刻度条件格式中最小值、中点值或最大值阈值的条件。

IColorScaleCriterion 定义颜色刻度规则中的一个阈值,包括阈值的确定方式以及分配给该阈值的颜色。通过 IColorScale.getColorScaleCriteria() 使用它,可以检查或自定义双色或三色刻度中的条件。


 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
    获取一个 IFormatColor 对象,该对象指定分配给颜色刻度条件格式阈值的颜色。
    int
    获取一个整数值,该值指示条件表示哪个阈值。
    返回 ConditionValueTypes 枚举的常量之一,该常量指定如何确定数据条或颜色刻度条件格式的阈值。
    获取颜色刻度条件格式的最小值、中点值或最大值阈值。
    void
    设置 ConditionValueTypes 枚举的常量之一,该常量指定如何确定数据条或颜色刻度条件格式的阈值。
    void
    设置颜色刻度条件格式的最小值、中点值或最大值阈值。
  • Method Details

    • getFormatColor

      IFormatColor getFormatColor()
      获取一个 IFormatColor 对象,该对象指定分配给颜色刻度条件格式阈值的颜色。

      使用返回的对象可以检查或修改此条件所表示的最小值、中点值或最大值阈值的颜色。

      
       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:
      定义此阈值颜色的 IFormatColor 对象。
    • getIndex

      int getIndex()
      获取一个整数值,该值指示条件表示哪个阈值。

      使用此方法可以识别条件对应于颜色刻度条件格式中的最小值阈值、中点阈值还是最大值阈值。

      
       IColorScale colorScale = worksheet.getRange("A1:A5").getFormatConditions()
               .addColorScale(ColorScaleType.ThreeColorScale);
       IColorScaleCriterion criterion = colorScale.getColorScaleCriteria().get(1);
       int index = criterion.getIndex();
       
      Returns:
      指示条件表示哪个阈值的整数值。
    • getType

      返回 ConditionValueTypes 枚举的常量之一,该常量指定如何确定数据条或颜色刻度条件格式的阈值。

      使用此方法可以检查条件阈值是基于数字、百分比、百分位、公式,还是自动最小值或最大值。

      
       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:
      ConditionValueTypes 枚举的常量之一,指示如何确定颜色刻度条件的阈值。
    • setType

      void setType(ConditionValueTypes value)
      设置 ConditionValueTypes 枚举的常量之一,该常量指定如何确定数据条或颜色刻度条件格式的阈值。

      使用此方法可以定义条件阈值是基于绝对数字、百分比、百分位、公式,还是自动最小值或最大值。当类型需要显式阈值时,请使用 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 - 指定如何确定阈值的 ConditionValueTypes 常量。
    • getValue

      Object getValue()
      获取颜色刻度条件格式的最小值、中点值或最大值阈值。

      仅当条件类型通过 setType(ConditionValueTypes) 设置为 ConditionValueTypes.Number、ConditionValueTypes.Percent、 ConditionValueTypes.Percentile 或 ConditionValueTypes.Formula 时,才可以设置该值。如果阈值类型为公式,则返回的值为 String。公式必须返回单个数字。

      
       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:
      条件的阈值。对于基于数字、百分比和百分位的阈值,返回数值;对于基于公式的阈值,返回 String。
    • setValue

      void setValue(Object value)
      设置颜色刻度条件格式的最小值、中点值或最大值阈值。

      仅当条件类型通过 setType(ConditionValueTypes) 设置为 ConditionValueTypes.Number、ConditionValueTypes.Percent、 ConditionValueTypes.Percentile 或 ConditionValueTypes.Formula 时,才可以设置该值。如果阈值类型为公式,则该值应设置为 String。公式必须返回单个数字。

      
       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 - 条件的阈值。为基于数字、百分比和百分位的阈值设置数值,或为基于公式的阈值设置 String。