FormatConditionCollection

FormatConditionCollection class

Represents conditional formatting. The FormatConditions can contain up to three conditional formats.

Properties

NameTypeDescription
CountNumberGets the count of the conditions.
RangeCountNumberGets count of conditionally formatted ranges.
Item (int)FormatConditionGets the formatting condition by index.

Methods

NameDescription
addAdds a formatting condition and effected cell rang to the FormatConditions The FormatConditions can contain up to three
addAreaAdds a conditional formatted cell range.
addConditionAdds a formatting condition.
getCellAreaGets the conditional formatted cell range by index.
removeAreaRemoves conditional formatted cell range by index.
removeConditionRemoves the formatting condition by index.

FormatConditionCollection.Count property

Gets the count of the conditions.

Type: Number

FormatConditionCollection.RangeCount property

Gets count of conditionally formatted ranges.

Type: Number

FormatConditionCollection.Item (int) property

Gets the formatting condition by index.

Type: FormatCondition

add(cellArea, type, operatorType, formula1, formula2)

Adds a formatting condition and effected cell rang to the FormatConditions The FormatConditions can contain up to three conditional formats. References to the other sheets are not allowed in the formulas of conditional formatting.

ParameterTypeDescription
cellAreaCellAreaConditional formatted cell range.
typeNumberA FormatConditionType value. Type of conditional formatting.It could be one of the members of FormatConditionType.
operatorTypeNumberA OperatorType value. Comparison operator.It could be one of the members of OperatorType.
formula1StringThe value or expression associated with conditional formatting.
formula2StringThe value or expression associated with conditional formatting

Returns: [0]:Formatting condition object index;[1] Effected cell rang index.

addArea(cellArea)

Adds a conditional formatted cell range.

ParameterTypeDescription
cellAreaCellAreaConditional formatted cell range.

Returns: Conditional formatted cell rang index.

addCondition(type, operatorType, formula1, formula2) (1 of 2)

Adds a formatting condition.

ParameterTypeDescription
typeNumberA FormatConditionType value. The type of format condition.
operatorTypeNumberA OperatorType value. The operator type
formula1StringThe value or expression associated with conditional formatting. 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 conditional formatting. The input format is same with formula1

Returns: Formatting condition object index;


addCondition(type) (2 of 2)

Add a format condition.

ParameterTypeDescription
typeNumberA FormatConditionType value. Format condition type.

Returns: Formatting condition object index;

getCellArea(index)

Gets the conditional formatted cell range by index.

ParameterTypeDescription
indexNumberthe index of the conditional formatted cell range.

Returns: the conditional formatted cell range

removeArea(index) (1 of 2)

Removes conditional formatted cell range by index.

ParameterTypeDescription
indexNumberThe index of the conditional formatted cell range to be removed.

removeArea(startRow, startColumn, totalRows, totalColumns) (2 of 2)

Remove conditional formatting int the range.

ParameterTypeDescription
startRowNumberThe startRow of the range.
startColumnNumberThe startColumn of the range.
totalRowsNumberThe number of rows of the range.
totalColumnsNumberThe number of columns of the range.

Returns: Returns TRUE, this FormatCondtionCollection should be removed.

removeCondition(index)

Removes the formatting condition by index.

ParameterTypeDescription
indexNumberThe index of the formatting condition to be removed.