Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

ExcelScript.PresetCriteriaConditionalFormat interface

Package:
ExcelScript

Represents the preset criteria conditional format such as above average, below average, unique values, contains blank, nonblank, error, and noerror.

Remarks

Used by

Examples

/**
 * This script applies a conditional format that uses a preset criterion.
 * Any cell in row 1 will have the color fill set to green if it is a duplicate value
 * (of anything else in row 1).
 */
function main(workbook: ExcelScript.Workbook) {
 // Get the range for row 1.
 const sheet = workbook.getActiveWorksheet();
 const formattedRange = sheet.getRange("1:1");

 // Add new conditional formatting to that range.
 const conditionalFormat = formattedRange.addConditionalFormat(
 ExcelScript.ConditionalFormatType.presetCriteria);

 // Set the conditional formatting to apply a green fill.
 const presetFormat: ExcelScript.PresetCriteriaConditionalFormat = conditionalFormat.getPreset();
 presetFormat.getFormat().getFill().setColor("green");

 // Set a rule to apply the conditional format when values are duplicated in the range.
 const duplicateRule: ExcelScript.ConditionalPresetCriteriaRule = {
 criterion: ExcelScript.ConditionalFormatPresetCriterion.duplicateValues
 };
 presetFormat.setRule(duplicateRule);
}

Methods

getFormat()

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

getRule()

The rule of the conditional format.

setRule(rule)

The rule of the conditional format.

Method Details

getFormat()

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

getFormat(): ConditionalRangeFormat;

Returns

getRule()

The rule of the conditional format.

getRule(): ConditionalPresetCriteriaRule;

Returns

setRule(rule)

The rule of the conditional format.

setRule(rule: ConditionalPresetCriteriaRule): void;

Parameters

Returns

void


Feedback

Was this page helpful?