[]
Sheets.ConditionalFormatting.ScaleRule
↳ ScaleRule
↳↳ DataBarRule
↳↳ IconSetRule
• new ScaleRule(ruleType
, minType?
, minValue?
, minColor?
, midType?
, midValue?
, midColor?
, maxType?
, maxValue?
, maxColor?
, ranges?
)
刻度条件规则
@extends
GC.Spread.Sheets.ConditionalFormatting.ConditionRuleBase
代码示例
var scale = new GC.Spread.Sheets.ConditionalFormatting.ScaleRule();
scale.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.threeScaleRule);
scale.midColor("red");
scale.midType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.midValue(50);
scale.maxColor("blue");
scale.maxType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.maxValue(100);
scale.minColor("yellow");
scale.minType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.minValue(10);
scale.ranges([new GC.Spread.Sheets.Range(0, 0, 10, 3)]);
activeSheet.conditionalFormats.addRule(scale);
activeSheet.setValue(0,0, 1,3);
activeSheet.setValue(1,0, 50,3);
activeSheet.setValue(2,0, 100,3);
属性名 | 类型 | 说明 |
---|---|---|
ruleType |
RuleType |
规则类型 |
minType? |
ScaleValueType |
最小的比例类型 |
minValue? |
number |
最小刻度值 |
minColor? |
string |
最小刻度颜色 |
midType? |
ScaleValueType |
中点刻度类型 |
midValue? |
number |
中点刻度值 |
midColor? |
string |
中点刻度颜色 |
maxType? |
ScaleValueType |
最大的比例类型 |
maxValue? |
number |
最大刻度值 |
maxColor? |
string |
最大刻度颜色 |
ranges? |
Range [] |
区域 |
▸ condition(value?
): any
获取或设置规则的基本条件
属性名 | 类型 | 说明 |
---|---|---|
value? |
Condition |
规则的基本条件 |
any
如果未设置任何值,则返回规则的基本条件否则,返回条件规则
▸ contains(row
, column
): boolean
确定单元格区域是否包含指定行和列的单元格
属性名 | 类型 | 说明 |
---|---|---|
row |
number |
行索引 |
column |
number |
列索引 |
boolean
如果单元格区域包含指定行和列中的单元格,返回true;否则返回false
▸ createCondition(): Condition
创建条件规则
条件
ConditionRuleBase.createCondition
▸ evaluate(evaluator
, baseRow
, baseColumn
, actual
): any
如果单元格满足条件,则返回规则的指定值
属性名 | 类型 | 说明 |
---|---|---|
evaluator |
Object |
计算器 |
baseRow |
number |
行索引 |
baseColumn |
number |
列索引 |
actual |
Object |
用于计算的实际价值对象 |
any
如果单元格满足条件,则为规则的指定值
▸ getExpected(): Style
获取基本规则的样式
代码示例
//This example uses the getExpected method.
activeSheet.suspendPaint();
var style = new GC.Spread.Sheets.Style();
style.backColor = "green";
var ranges = [new GC.Spread.Sheets.Range(0, 0, 10, 1)];
activeSheet.conditionalFormats.addUniqueRule(style, ranges);
var data = [50, 50, 11, 5, 3, 6, 7, 8, 7, 11];
var condition = activeSheet.conditionalFormats.getRules()[0];
for (var i = 0; i < 10;i++){
activeSheet.setValue(i, 0, data[i]);
}
activeSheet.resumePaint();
console.log(condition.getExpected());
▸ intersects(row
, column
, rowCount
, columnCount
): boolean
此规则的区域是否与另一个区域相交
代码示例
//This example uses the intersects method.
activeSheet.suspendPaint();
var style = new GC.Spread.Sheets.Style();
style.backColor = "green";
var ranges = [new GC.Spread.Sheets.Range(0, 0, 10, 1)];
activeSheet.conditionalFormats.addUniqueRule(style, ranges);
var data = [50, 50, 11, 5, 3, 6, 7, 8, 7, 11];
var condition = activeSheet.conditionalFormats.getRules()[0];
for (var i = 0; i < 10; i++) {
activeSheet.setValue(i, 0, data[i]);
}
activeSheet.resumePaint();
activeSheet.bind(GC.Spread.Sheets.Events.SelectionChanged, function(e, info) {
var selection = info.newSelections[0];
var result = condition.intersects(selection.row, selection.col, selection.rowCount, selection.colCount);
if (result) {
alert("current selection is intersects with condition formatting range");
} else {
alert("current selection is not intersects with condition formatting range");
}
});
属性名 | 类型 | 说明 |
---|---|---|
row |
number |
行索引 |
column |
number |
列索引 |
rowCount |
number |
行数 |
columnCount |
number |
列数 |
boolean
如果此规则的区域与另一个区域相交,返回true;否则返回false
▸ isScaleRule(): boolean
此规则是否为缩放规则
boolean
如果此规则是缩放规则,返回true;否则返回false
▸ maxColor(value?
): any
获取或设置最大色阶
代码示例
var rule = new GC.Spread.Sheets.ConditionalFormatting.ScaleRule();
rule.ranges([new GC.Spread.Sheets.Range(0,0,10,3)]);
rule.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.twoScaleRule);
rule.minType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
rule.minValue(10);
rule.minColor("Yellow");
rule.maxType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
rule.maxValue(100);
rule.maxColor("Blue");
activeSheet.conditionalFormats.addRule(rule);
activeSheet.setValue(0,0, 1,3);
activeSheet.setValue(1,0, 50,3);
activeSheet.setValue(2,0, 100,3);
属性名 | 类型 | 说明 |
---|---|---|
value? |
string |
最大色阶 |
any
如果未设置任何值,则返回最大色阶;否则,返回刻度规则
▸ maxType(value?
): any
获取或设置最大刻度类型
代码示例
var scale = new GC.Spread.Sheets.ConditionalFormatting.ScaleRule();
scale.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.threeScaleRule);
scale.midColor("red");
scale.midType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.midValue(50);
scale.maxColor("blue");
scale.maxType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.maxValue(100);
scale.minColor("yellow");
scale.minType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.minValue(10);
scale.ranges([new GC.Spread.Sheets.Range(0, 0, 10, 3)]);
activeSheet.conditionalFormats.addRule(scale);
activeSheet.setValue(0,0, 1,3);
activeSheet.setValue(1,0, 50,3);
activeSheet.setValue(2,0, 100,3);
属性名 | 类型 | 说明 |
---|---|---|
value? |
ScaleValueType |
最大的比例类型 |
any
如果未设置任何值,则返回最大刻度类型否则,返回刻度规则
▸ maxValue(value?
): any
获取或设置最大刻度值
代码示例
var scale = new GC.Spread.Sheets.ConditionalFormatting.ScaleRule();
scale.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.twoScaleRule);
scale.maxColor("blue");
scale.maxType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.maxValue(100);
scale.minColor("yellow");
scale.minType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.minValue(10);
scale.ranges([new GC.Spread.Sheets.Range(0, 0, 10, 3)]);
activeSheet.conditionalFormats.addRule(scale);
activeSheet.setValue(0,0, 1,3);
activeSheet.setValue(1,0, 50,3);
activeSheet.setValue(2,0, 100,3);
alert("Color: " + scale.maxColor() + " Type: " + scale.maxType() + " Value: " + scale.maxValue());
属性名 | 类型 | 说明 |
---|---|---|
value? |
number |
最大刻度值 |
any
如果未设置任何值,则返回最大刻度值否则,返回刻度规则
▸ midColor(value?
): any
获取或设置中点刻度颜色
代码示例
var scale = new GC.Spread.Sheets.ConditionalFormatting.ScaleRule();
scale.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.threeScaleRule);
scale.midColor("red");
scale.midType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.midValue(50);
scale.maxColor("blue");
scale.maxType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.maxValue(100);
scale.minColor("yellow");
scale.minType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.minValue(10);
scale.ranges([new GC.Spread.Sheets.Range(0, 0, 10, 3)]);
activeSheet.conditionalFormats.addRule(scale);
activeSheet.setValue(0,0, 1,3);
activeSheet.setValue(1,0, 50,3);
activeSheet.setValue(2,0, 100,3);
属性名 | 类型 | 说明 |
---|---|---|
value? |
string |
中点刻度颜色 |
any
如果未设置任何值,则返回中点刻度颜色否则,返回刻度规则
▸ midType(value?
): any
获取或设置中点刻度类型
代码示例
var scale = new GC.Spread.Sheets.ConditionalFormatting.ScaleRule();
scale.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.threeScaleRule);
scale.midColor("red");
scale.midType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.midValue(50);
scale.maxColor("blue");
scale.maxType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.maxValue(100);
scale.minColor("yellow");
scale.minType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.minValue(10);
scale.ranges([new GC.Spread.Sheets.Range(0, 0, 10, 3)]);
activeSheet.conditionalFormats.addRule(scale);
activeSheet.setValue(0,0, 1,3);
activeSheet.setValue(1,0, 50,3);
activeSheet.setValue(2,0, 100,3);
属性名 | 类型 | 说明 |
---|---|---|
value? |
ScaleValueType |
中点刻度类型 |
any
如果未设置任何值,则返回中点刻度类型否则,返回刻度规则
▸ midValue(value?
): any
获取或设置中点刻度值
代码示例
var scale = new GC.Spread.Sheets.ConditionalFormatting.ScaleRule();
scale.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.threeScaleRule);
scale.midColor("red");
scale.midType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.midValue(50);
scale.maxColor("blue");
scale.maxType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.maxValue(100);
scale.minColor("yellow");
scale.minType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
scale.minValue(10);
scale.ranges([new GC.Spread.Sheets.Range(0, 0, 10, 3)]);
activeSheet.conditionalFormats.addRule(scale);
activeSheet.setValue(0,0, 1,3);
activeSheet.setValue(1,0, 50,3);
activeSheet.setValue(2,0, 100,3);
属性名 | 类型 | 说明 |
---|---|---|
value? |
number |
中点刻度值 |
any
如果未设置任何值,则返回中点刻度值否则,返回刻度规则
▸ minColor(value?
): any
获取或设置最小刻度颜色
代码示例
var rule = new GC.Spread.Sheets.ConditionalFormatting.ScaleRule();
rule.ranges([new GC.Spread.Sheets.Range(0,0,10,3)]);
rule.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.twoScaleRule);
rule.minType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
rule.minValue(10);
rule.minColor("Yellow");
rule.maxType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
rule.maxValue(100);
rule.maxColor("Blue");
activeSheet.conditionalFormats.addRule(rule);
activeSheet.setValue(0,0, 1,3);
activeSheet.setValue(1,0, 50,3);
activeSheet.setValue(2,0, 100,3);
属性名 | 类型 | 说明 |
---|---|---|
value? |
string |
最小刻度颜色 |
any
如果未设置任何值,则返回最小刻度颜色否则,将返回刻度规则
▸ minType(value?
): any
获取或设置最小刻度的类型
代码示例
activeSheet.setValue(0,0,1,3);
activeSheet.setValue(1,0,15,3);
activeSheet.setValue(2,0,25,3);
activeSheet.setValue(3,0,-1,3);
var dataBarRule = new GC.Spread.Sheets.ConditionalFormatting.DataBarRule();
dataBarRule.ranges([new GC.Spread.Sheets.Range(0,0,4,1)]);
dataBarRule.minType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
dataBarRule.minValue(-1);
dataBarRule.maxType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
dataBarRule.maxValue(40);
dataBarRule.color("green");
dataBarRule.showBorder(true);
dataBarRule.borderColor("orange");
dataBarRule.dataBarDirection(GC.Spread.Sheets.ConditionalFormatting.BarDirection.leftToRight);
dataBarRule.negativeFillColor("yellow");
dataBarRule.useNegativeFillColor(true);
dataBarRule.negativeBorderColor("red");
dataBarRule.useNegativeBorderColor(true);
dataBarRule.axisPosition(GC.Spread.Sheets.ConditionalFormatting.DataBarAxisPosition.automatic);
dataBarRule.axisColor("blue");
dataBarRule.showBarOnly(false);
activeSheet.conditionalFormats.addRule(dataBarRule);
属性名 | 类型 | 说明 |
---|---|---|
value? |
ScaleValueType |
最小刻度的类型 |
any
如果未设置任何值,则返回最小刻度的类型否则,返回刻度规则
▸ minValue(value?
): any
获取或设置最小刻度值
代码示例
activeSheet.setValue(0,0,1,3);
activeSheet.setValue(1,0,15,3);
activeSheet.setValue(2,0,25,3);
activeSheet.setValue(3,0,-1,3);
var dataBarRule = new GC.Spread.Sheets.ConditionalFormatting.DataBarRule();
dataBarRule.ranges([new GC.Spread.Sheets.Range(0,0,4,1)]);
dataBarRule.minType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
dataBarRule.minValue(-1);
dataBarRule.maxType(GC.Spread.Sheets.ConditionalFormatting.ScaleValueType.number);
dataBarRule.maxValue(40);
dataBarRule.color("green");
dataBarRule.showBorder(true);
dataBarRule.borderColor("orange");
dataBarRule.dataBarDirection(GC.Spread.Sheets.ConditionalFormatting.BarDirection.leftToRight);
dataBarRule.negativeFillColor("yellow");
dataBarRule.useNegativeFillColor(true);
dataBarRule.negativeBorderColor("red");
dataBarRule.useNegativeBorderColor(true);
dataBarRule.axisPosition(GC.Spread.Sheets.ConditionalFormatting.DataBarAxisPosition.automatic);
dataBarRule.axisColor("blue");
dataBarRule.showBarOnly(false);
activeSheet.conditionalFormats.addRule(dataBarRule);
属性名 | 类型 | 说明 |
---|---|---|
value? |
number |
最小刻度值 |
any
如果未设置任何值,则返回最小刻度值;否则,返回刻度规则
▸ priority(value?
): any
获取或设置规则的优先级
属性名 | 类型 | 说明 |
---|---|---|
value? |
number |
规则的优先级 |
any
如果未设置任何值,则返回规则的优先级否则,返回条件规则
▸ ranges(value?
): any
获取或设置条件规则区域
代码示例
var style = new GC.Spread.Sheets.Style();
style.backColor = "green";
var ranges = [new GC.Spread.Sheets.Range(0, 0, 10, 1)];
activeSheet.conditionalFormats.addUniqueRule(style, ranges);
activeSheet.setValue(0, 0, 50);
activeSheet.setValue(1, 0, 50);
activeSheet.setValue(2, 0, 11);
activeSheet.setValue(3, 0, 5);
属性名 | 类型 | 说明 |
---|---|---|
value? |
Range [] |
条件规则区域 |
any
如果未设置任何值,则返回条件规则区域否则,返回条件规则
▸ reset(): void
重置规则
代码示例
activeSheet.setArray(0, 0, [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
var style = new GC.Spread.Sheets.Style();
style.backColor = "red";
style.foreColor = "black";
var cell = new GC.Spread.Sheets.ConditionalFormatting.NormalConditionRule();
cell.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.cellValueRule);
cell.operator(GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.greaterThan);
cell.value1(2);
cell.ranges([new GC.Spread.Sheets.Range(0, 0, 10, 1)]);
cell.style(style);
activeSheet.conditionalFormats.addRule(cell);
var style = new GC.Spread.Sheets.Style();
style.cellButtons = [{
caption: "Reset",
useButtonStyle: true,
width: 60,
command: function(sheet) {
cell.reset();
sheet.resumePaint();
}
}];
activeSheet.setStyle(16, 4, style);
void
▸ ruleType(value?
): any
获取或设置条件规则类型
代码示例
//本示例使用ruleType方法
activeSheet.setArray(0,0,[1,2,3,4,5,6,7,8,9,10]);
var style = new GC.Spread.Sheets.Style();
style.backColor = "red";
style.foreColor = "black";
var cell = new GC.Spread.Sheets.ConditionalFormatting.NormalConditionRule();
cell.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.cellValueRule);
cell.operator(GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.greaterThan);
cell.value1(5);
cell.ranges([new GC.Spread.Sheets.Range(0, 0, 10, 1)]);
cell.style(style);
activeSheet.conditionalFormats.addRule(cell);
var style1 = new GC.Spread.Sheets.Style();
style1.foreColor = "red";
var top = new GC.Spread.Sheets.ConditionalFormatting.NormalConditionRule();
top.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.top10Rule);
top.type(GC.Spread.Sheets.ConditionalFormatting.Top10ConditionType.top);
top.rank(3);
top.style(style1);
top.ranges([new GC.Spread.Sheets.Range(0, 0, 10, 1)]);
top.stopIfTrue(true);
activeSheet.conditionalFormats.addRule(top);
属性名 | 类型 | 说明 |
---|---|---|
value? |
RuleType |
条件规则类型 |
any
如果未设置任何值,则返回条件规则类型否则,返回条件规则
▸ stopIfTrue(value?
): boolean
获取条件计算为true时计算是否停止
属性名 | 类型 |
---|---|
value? |
boolean |
boolean
▸ style(value?
): any
获取或设置规则的样式
代码示例
//本示例应用了多个规则
activeSheet.setArray(0,0,[1,2,3,4,5,6,7,8,9,10]);
var style = new GC.Spread.Sheets.Style();
style.backColor = "red";
style.foreColor = "black";
var cell = new GC.Spread.Sheets.ConditionalFormatting.NormalConditionRule();
cell.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.cellValueRule);
cell.operator(GC.Spread.Sheets.ConditionalFormatting.ComparisonOperators.greaterThan);
cell.value1(5);
cell.ranges([new GC.Spread.Sheets.Range(0, 0, 10, 1)]);
cell.style(style);
activeSheet.conditionalFormats.addRule(cell);
var style1 = new GC.Spread.Sheets.Style();
style1.foreColor = "red";
var top = new GC.Spread.Sheets.ConditionalFormatting.NormalConditionRule();
top.ruleType(GC.Spread.Sheets.ConditionalFormatting.RuleType.top10Rule);
top.type(GC.Spread.Sheets.ConditionalFormatting.Top10ConditionType.top);
top.rank(3);
top.style(style1);
top.ranges([new GC.Spread.Sheets.Range(0, 0, 10, 1)]);
top.stopIfTrue(true);
activeSheet.conditionalFormats.addRule(top);
属性名 | 类型 | 说明 |
---|---|---|
value? |
Style |
规则的样式 |
any
如果未设置任何值,则返回规则的样式否则,返回条件规则