FormatCondition

FormatCondition class

Represents conditional formatting condition.

Properties

NameTypeDescription
Formula1StringGets and sets the value or expression associated with conditional formatting. Please add all areas before setting formul
Formula2StringGets and sets the value or expression associated with conditional formatting. Please add all areas before setting formul
OperatorintGets and sets the conditional format operator type. The value of the property is OperatorType integer constant.
StopIfTruebooleanTrue, no rules with lower priority may be applied over this rule, when this rule evaluates to true. Only applies for Exc
PriorityintThe priority of this conditional formatting rule. This value is used to determine which format should be evaluated and r
StyleStyleGets or setts style of conditional formatted cell ranges.
TypeintGets and sets whether the conditional format Type. The value of the property is FormatConditionType integer constant.
IconSetIconSetGet the conditional formatting’s “IconSet” instance. The default instance’s IconSetType is TrafficLights31. Valid only f
DataBarDataBarGet the conditional formatting’s “DataBar” instance. The default instance’s color is blue. Valid only for type is DataBa
ColorScaleColorScaleGet the conditional formatting’s “ColorScale” instance. The default instance is a “green-yellow-red” 3ColorScale . Valid
Top10Top10Get the conditional formatting’s “Top10” instance. The default instance’s rule highlights cells whose values fall in the
AboveAverageAboveAverageGet the conditional formatting’s “AboveAverage” instance. The default instance’s rule highlights cells that are above th
TextStringThe text value in a “text contains” conditional formatting rule. Valid only for type = containsText, notContainsText, be
TimePeriodintThe applicable time period in a “date occurring…” conditional formatting rule. Valid only for type = timePeriod. The def

Methods

NameDescription
getFormula1Gets the value or expression associated with this format condition.
getFormula2Gets the value or expression associated with this format condition.
setFormulasSets the value or expression associated with this format condition.
setFormula1Sets the value or expression associated with this format condition.
setFormula2Sets the value or expression associated with this format condition.

FormatCondition.Formula1 property

Gets and sets the value or expression associated with conditional formatting. Please add all areas before setting formula. For setting formula for this condition, if the input value starts with ‘=’, then it will be taken as formula. Otherwise it will be taken as plain value(text, number, bool). For text value that starts with ‘=’, user may input it as formula in format: “="=…"”.

Type: String

FormatCondition.Formula2 property

Gets and sets the value or expression associated with conditional formatting. Please add all areas before setting formula. For setting formula for this condition, if the input value starts with ‘=’, then it will be taken as formula. Otherwise it will be taken as plain value(text, number, bool). For text value that starts with ‘=’, user may input it as formula in format: “="=…"”.

Type: String

FormatCondition.Operator property

Gets and sets the conditional format operator type. The value of the property is OperatorType integer constant.

Type: int

FormatCondition.StopIfTrue property

True, no rules with lower priority may be applied over this rule, when this rule evaluates to true. Only applies for Excel 2007;

Type: boolean

FormatCondition.Priority property

The priority of this conditional formatting rule. This value is used to determine which format should be evaluated and rendered. Lower numeric values are higher priority than higher numeric values, where ‘1’ is the highest priority.

Type: int

FormatCondition.Style property

Gets or setts style of conditional formatted cell ranges.

Type: Style

FormatCondition.Type property

Gets and sets whether the conditional format Type. The value of the property is FormatConditionType integer constant.

Type: int

FormatCondition.IconSet property

Get the conditional formatting’s “IconSet” instance. The default instance’s IconSetType is TrafficLights31. Valid only for type = IconSet.

Type: IconSet

FormatCondition.DataBar property

Get the conditional formatting’s “DataBar” instance. The default instance’s color is blue. Valid only for type is DataBar.

Type: DataBar

FormatCondition.ColorScale property

Get the conditional formatting’s “ColorScale” instance. The default instance is a “green-yellow-red” 3ColorScale . Valid only for type = ColorScale.

Type: ColorScale

FormatCondition.Top10 property

Get the conditional formatting’s “Top10” instance. The default instance’s rule highlights cells whose values fall in the top 10 bracket. Valid only for type is Top10.

Type: Top10

FormatCondition.AboveAverage property

Get the conditional formatting’s “AboveAverage” instance. The default instance’s rule highlights cells that are above the average for all values in the range. Valid only for type = AboveAverage.

Type: AboveAverage

FormatCondition.Text property

The text value in a “text contains” conditional formatting rule. Valid only for type = containsText, notContainsText, beginsWith and endsWith. The default value is null.

Type: String

FormatCondition.TimePeriod property

The applicable time period in a “date occurring…” conditional formatting rule. Valid only for type = timePeriod. The default value is TimePeriodType.Today. The value of the property is TimePeriodType integer constant.

Type: int

getFormula1(isR1C1, isLocal) (1 of 3)

Gets the value or expression associated with this format condition.

ParameterTypeDescription
isR1C1booleanWhether the formula needs to be formatted as R1C1.
isLocalbooleanWhether the formula needs to be formatted by locale.

Returns: The value or expression associated with this format condition.


getFormula1(isR1C1, isLocal, row, column) (2 of 3)

Gets the value or expression of the conditional formatting of the cell.

The given cell must be contained by this conditional formatting, otherwise null will be returned.

ParameterTypeDescription
isR1C1booleanWhether the formula needs to be formatted as R1C1.
isLocalbooleanWhether the formula needs to be formatted by locale.
rowintThe row index.
columnintThe column index.

Returns: The value or expression associated with the conditional formatting of the cell.


getFormula1(row, column) (3 of 3)

Gets the formula of the conditional formatting of the cell.

ParameterTypeDescription
rowintThe row index.
columnintThe column index.

Returns: The formula.

getFormula2(isR1C1, isLocal) (1 of 3)

Gets the value or expression associated with this format condition.

ParameterTypeDescription
isR1C1booleanWhether the formula needs to be formatted as R1C1.
isLocalbooleanWhether the formula needs to be formatted by locale.

Returns: The value or expression associated with this format condition.


getFormula2(isR1C1, isLocal, row, column) (2 of 3)

Gets the value or expression of the conditional formatting of the cell.

The given cell must be contained by this conditional formatting, otherwise null will be returned.

ParameterTypeDescription
isR1C1booleanWhether the formula needs to be formatted as R1C1.
isLocalbooleanWhether the formula needs to be formatted by locale.
rowintThe row index.
columnintThe column index.

Returns: The value or expression associated with the conditional formatting of the cell.


getFormula2(row, column) (3 of 3)

Gets the formula of the conditional formatting of the cell.

ParameterTypeDescription
rowintThe row index.
columnintThe column index.

Returns: The formula.

setFormulas(formula1, formula2, isR1C1, isLocal)

Sets the value or expression associated with this format condition.

ParameterTypeDescription
formula1StringThe value or expression associated with this format condition. If the input value starts with ‘=’, then it will be taken as formula. Otherwise it will be taken as plain value(text, number, bool). For text value that starts with ‘=’, user may input it as formula in format: “="=…"”.
formula2StringThe value or expression associated with this format condition. The input format is same with formula1
isR1C1booleanWhether the formula is R1C1 formula.
isLocalbooleanWhether the formula is locale formatted.

setFormula1(formula, isR1C1, isLocal)

Sets the value or expression associated with this format condition.

ParameterTypeDescription
formulaStringThe value or expression associated with this format condition. If the input value starts with ‘=’, then it will be taken as formula. Otherwise it will be taken as plain value(text, number, bool). For text value that starts with ‘=’, user may input it as formula in format: “="=…"”.
isR1C1booleanWhether the formula is R1C1 formula.
isLocalbooleanWhether the formula is locale formatted.

setFormula2(formula, isR1C1, isLocal)

Sets the value or expression associated with this format condition.

ParameterTypeDescription
formulaStringThe value or expression associated with this format condition. If the input value starts with ‘=’, then it will be taken as formula. Otherwise it will be taken as plain value(text, number, bool). For text value that starts with ‘=’, user may input it as formula in format: “="=…"”.
isR1C1booleanWhether the formula is R1C1 formula.
isLocalbooleanWhether the formula is locale formatted.