ExcelScript.IconSetConditionalFormat interface

Represents an icon set criteria for conditional formatting.

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);
  const iconSetFormat: ExcelScript.IconSetConditionalFormat = conditionalFormatting.getIconSet();
  // Use the "3 Traffic Lights (Unrimmed)" set.
  iconSetFormat.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.
  iconSetFormat.setCriteria([
    {
      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
    }]);
}

Methods

getCriteria()

An array of criteria and icon sets for the rules and potential custom icons for conditional icons. Note that for the first criterion only the custom icon can be modified, while type, formula, and operator will be ignored when set.

getReverseIconOrder()

If true, reverses the icon orders for the icon set. Note that this cannot be set if custom icons are used.

getShowIconOnly()

If true, hides the values and only shows icons.

getStyle()

If set, displays the icon set option for the conditional format.

setCriteria(criteria)

An array of criteria and icon sets for the rules and potential custom icons for conditional icons. Note that for the first criterion only the custom icon can be modified, while type, formula, and operator will be ignored when set.

setReverseIconOrder(reverseIconOrder)

If true, reverses the icon orders for the icon set. Note that this cannot be set if custom icons are used.

setShowIconOnly(showIconOnly)

If true, hides the values and only shows icons.

setStyle(style)

If set, displays the icon set option for the conditional format.

Method Details

getCriteria()

An array of criteria and icon sets for the rules and potential custom icons for conditional icons. Note that for the first criterion only the custom icon can be modified, while type, formula, and operator will be ignored when set.

getCriteria(): ConditionalIconCriterion[];

Returns

getReverseIconOrder()

If true, reverses the icon orders for the icon set. Note that this cannot be set if custom icons are used.

getReverseIconOrder(): boolean;

Returns

boolean

getShowIconOnly()

If true, hides the values and only shows icons.

getShowIconOnly(): boolean;

Returns

boolean

getStyle()

If set, displays the icon set option for the conditional format.

getStyle(): IconSet;

Returns

setCriteria(criteria)

An array of criteria and icon sets for the rules and potential custom icons for conditional icons. Note that for the first criterion only the custom icon can be modified, while type, formula, and operator will be ignored when set.

setCriteria(criteria: ConditionalIconCriterion[]): void;

Parameters

Returns

void

setReverseIconOrder(reverseIconOrder)

If true, reverses the icon orders for the icon set. Note that this cannot be set if custom icons are used.

setReverseIconOrder(reverseIconOrder: boolean): void;

Parameters

reverseIconOrder

boolean

Returns

void

setShowIconOnly(showIconOnly)

If true, hides the values and only shows icons.

setShowIconOnly(showIconOnly: boolean): void;

Parameters

showIconOnly

boolean

Returns

void

setStyle(style)

If set, displays the icon set option for the conditional format.

setStyle(style: IconSet): void;

Parameters

Returns

void