ExcelScript.ConditionalTopBottomRule interface

Represents the rule of the top/bottom conditional format.

Remarks

Examples

/**
 * This sample applies conditional formatting to the currently used range in the worksheet. 
 * The conditional formatting is a pink fill for the 5 lowest values.
 */
function main(workbook: ExcelScript.Workbook) {
  // Get the current worksheet.
  let selectedSheet = workbook.getActiveWorksheet();

  // Get the used range in the worksheet.
  let range = selectedSheet.getUsedRange();

  // Set the fill color to pink for the lowest 5 values in the range.
  let conditionalFormat = range.addConditionalFormat(ExcelScript.ConditionalFormatType.topBottom)
  conditionalFormat.getTopBottom().getFormat().getFill().setColor("pink");
  conditionalFormat.getTopBottom().setRule({
    rank: 5, /* The numerical threshold. */
    type: ExcelScript.ConditionalTopBottomCriterionType.bottomItems /* The type of the top/bottom condition. */
  });
}

Properties

rank

The rank between 1 and 1000 for numeric ranks or 1 and 100 for percent ranks.

type

Format values based on the top or bottom rank.

Property Details

rank

The rank between 1 and 1000 for numeric ranks or 1 and 100 for percent ranks.

rank: number;

Property Value

number

type

Format values based on the top or bottom rank.

type: ConditionalTopBottomCriterionType;

Property Value