ExcelScript.ConditionalIconCriterion interface
表示包含类型、值、运算符和可选自定义图标(如果未使用图标集)的图标条件。
注解
示例
/**
* This script applies icon set conditional formatting to a range.
*/
function main(workbook: ExcelScript.Workbook) {
// Get the range "A1:A5" on the current worksheet.
const sheet = workbook.getActiveWorksheet();
const range = sheet.getRange("A1:A5");
// Create icon set conditional formatting on the range.
const conditionalFormatting = range.addConditionalFormat(ExcelScript.ConditionalFormatType.iconSet);
// Use the "3 Traffic Lights (Unrimmed)" set.
conditionalFormatting.getIconSet().setStyle(ExcelScript.IconSet.threeTrafficLights1);
// Set the criteria to use a different icon for the bottom, middle, and top thirds of the values in the range.
const criteria: ExcelScript.ConditionalIconCriterion[] = [
{
formula: '=0', operator: ExcelScript.ConditionalIconCriterionOperator.greaterThanOrEqual,
type: ExcelScript.ConditionalFormatIconRuleType.percent
},
{
formula: '=33', operator: ExcelScript.ConditionalIconCriterionOperator.greaterThanOrEqual,
type: ExcelScript.ConditionalFormatIconRuleType.percent
},
{
formula: '=67', operator: ExcelScript.ConditionalIconCriterionOperator.greaterThanOrEqual,
type: ExcelScript.ConditionalFormatIconRuleType.percent
}];
conditionalFormatting.getIconSet().setCriteria(criteria);
}
属性
custom |
如果与默认图标集不同,则返回当前条件的自定义图标,否则 |
formula | 取决于类型的数字或公式。 |
operator |
|
type | 应基于的图标条件公式。 |
属性详细信息
customIcon
formula
取决于类型的数字或公式。
formula: string;
属性值
string
operator
greaterThan
或 greaterThanOrEqual
对于图标条件格式的每个规则类型。
operator: ConditionalIconCriterionOperator;