ExcelScript.ConditionalIconCriterion interface

Represents an icon criterion which contains a type, value, an operator, and an optional custom icon, if not using an icon set.

Remarks

Examples

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

Properties

customIcon

The custom icon for the current criterion, if different from the default icon set, else null will be returned.

formula

A number or a formula depending on the type.

operator

greaterThan or greaterThanOrEqual for each of the rule types for the icon conditional format.

type

What the icon conditional formula should be based on.

Property Details

customIcon

The custom icon for the current criterion, if different from the default icon set, else null will be returned.

customIcon?: Icon;

Property Value

formula

A number or a formula depending on the type.

formula: string;

Property Value

string

operator

greaterThan or greaterThanOrEqual for each of the rule types for the icon conditional format.

operator: ConditionalIconCriterionOperator;

Property Value

type

What the icon conditional formula should be based on.

type: ConditionalFormatIconRuleType;

Property Value