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);
}

属性

customIcon

如果与默认图标集不同,则返回当前条件的自定义图标,否则 null 将返回。

formula

取决于类型的数字或公式。

operator

greaterThangreaterThanOrEqual 对于图标条件格式的每个规则类型。

type

应基于的图标条件公式。

属性详细信息

customIcon

如果与默认图标集不同,则返回当前条件的自定义图标,否则 null 将返回。

customIcon?: Icon;

属性值

formula

取决于类型的数字或公式。

formula: string;

属性值

string

operator

greaterThangreaterThanOrEqual 对于图标条件格式的每个规则类型。

operator: ConditionalIconCriterionOperator;

属性值

type

应基于的图标条件公式。

type: ConditionalFormatIconRuleType;

属性值