[]
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());
IFormatColor 对象,该对象指定分配给颜色刻度条件格式阈值的颜色。intgetIndex()getType()ConditionValueTypes 枚举的常量之一,该常量指定如何确定数据条或颜色刻度条件格式的阈值。getValue()voidsetType(ConditionValueTypes value) ConditionValueTypes 枚举的常量之一,该常量指定如何确定数据条或颜色刻度条件格式的阈值。voidIFormatColor 对象,该对象指定分配给颜色刻度条件格式阈值的颜色。使用返回的对象可以检查或修改此条件所表示的最小值、中点值或最大值阈值的颜色。
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 对象。使用此方法可以识别条件对应于颜色刻度条件格式中的最小值阈值、中点阈值还是最大值阈值。
IColorScale colorScale = worksheet.getRange("A1:A5").getFormatConditions()
.addColorScale(ColorScaleType.ThreeColorScale);
IColorScaleCriterion criterion = colorScale.getColorScaleCriteria().get(1);
int index = criterion.getIndex();
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();
ConditionValueTypes 枚举的常量之一,指示如何确定颜色刻度条件的阈值。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);
value - 指定如何确定阈值的 ConditionValueTypes 常量。仅当条件类型通过 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();
String。仅当条件类型通过 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);
value - 条件的阈值。为基于数字、百分比和百分位的阈值设置数值,或为基于公式的阈值设置 String。