ExcelScript.TopBottomConditionalFormat interface

Represents a top/bottom conditional format.

Remarks

Examples

/**
 * This sample applies conditional formatting to the currently used range in the worksheet. 
 * The conditional formatting is a green fill for the top 10% of 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 green for the top 10% of values in the range.
  let conditionalFormat = range.addConditionalFormat(ExcelScript.ConditionalFormatType.topBottom)
  conditionalFormat.getTopBottom().getFormat().getFill().setColor("green");
  conditionalFormat.getTopBottom().setRule({
    rank: 10, /* The percentage threshold. */
    type: ExcelScript.ConditionalTopBottomCriterionType.topPercent /* The type of the top/bottom condition. */
  });
}

Methods

getFormat()

Returns a format object, encapsulating the conditional format's font, fill, borders, and other properties.

getRule()

The criteria of the top/bottom conditional format.

setRule(rule)

The criteria of the top/bottom conditional format.

Method Details

getFormat()

Returns a format object, encapsulating the conditional format's font, fill, borders, and other properties.

getFormat(): ConditionalRangeFormat;

Returns

getRule()

The criteria of the top/bottom conditional format.

getRule(): ConditionalTopBottomRule;

Returns

setRule(rule)

The criteria of the top/bottom conditional format.

setRule(rule: ConditionalTopBottomRule): void;

Parameters

Returns

void