Excel.ConditionalFormatRule class

Represents a rule, for all traditional rule/format pairings.

[ API set: ExcelApi 1.6 ]

Extends

Properties

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

formula

The formula, if required, to evaluate the conditional format rule on.

[ API set: ExcelApi 1.6 ]

formulaLocal

The formula, if required, to evaluate the conditional format rule on in the user's language.

[ API set: ExcelApi 1.6 ]

formulaR1C1

The formula, if required, to evaluate the conditional format rule on in R1C1-style notation.

[ API set: ExcelApi 1.6 ]

Methods

load(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.ConditionalFormatRule object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.ConditionalFormatRuleData) that contains shallow copies of any loaded child properties from the original object.

Property Details

context

The request context associated with the object. This connects the add-in's process to the Office host application's process.

context: RequestContext;

Property Value

RequestContext

formula

The formula, if required, to evaluate the conditional format rule on.

[ API set: ExcelApi 1.6 ]

formula: string;

Property Value

string

Examples

await Excel.run(async (context) => {
    const sheet = context.workbook.worksheets.getItem("Sample");
    const range = sheet.getRange("B8:E13");
    const conditionalFormat = range.conditionalFormats.add(Excel.ConditionalFormatType.custom);
    conditionalFormat.custom.rule.formula = '=IF(B8>INDIRECT("RC[-1]",0),TRUE)';
    conditionalFormat.custom.format.font.color = "green";

    await context.sync();
});

formulaLocal

The formula, if required, to evaluate the conditional format rule on in the user's language.

[ API set: ExcelApi 1.6 ]

formulaLocal: string;

Property Value

string

formulaR1C1

The formula, if required, to evaluate the conditional format rule on in R1C1-style notation.

[ API set: ExcelApi 1.6 ]

formulaR1C1: string;

Property Value

string

Method Details

load(option)

Queues up a command to load the specified properties of the object. You must call "context.sync()" before reading the properties.

load(option?: string | string[]): Excel.ConditionalFormatRule;

Parameters

option
string | string[]

A comma-delimited string or an array of strings that specify the properties to load.

Returns

Remarks

In addition to this signature, this method has the following signatures:

load(option?: { select?: string; expand?: string; }): Excel.ConditionalFormatRule - Where option.select is a comma-delimited string that specifies the properties to load, and options.expand is a comma-delimited string that specifies the navigation properties to load.

load(option?: { select?: string; expand?: string; top?: number; skip?: number }): Excel.ConditionalFormatRule - Only available on collection types. It is similar to the preceding signature. Option.top specifies the maximum number of collection items that can be included in the result. Option.skip specifies the number of items that are to be skipped and not included in the result. If option.top is specified, the result set will start after skipping the specified number of items.

toJSON()

Overrides the JavaScript toJSON() method in order to provide more useful output when an API object is passed to JSON.stringify(). (JSON.stringify, in turn, calls the toJSON method of the object that is passed to it.) Whereas the original Excel.ConditionalFormatRule object is an API object, the toJSON method returns a plain JavaScript object (typed as Excel.Interfaces.ConditionalFormatRuleData) that contains shallow copies of any loaded child properties from the original object.

toJSON(): Excel.Interfaces.ConditionalFormatRuleData;

Returns