FormatConditionCollection

FormatConditionCollection class

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

Properties

NameTypeDescription
CountintGets the count of the conditions.
RangeCountintGets 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: int

FormatConditionCollection.RangeCount property

Gets count of conditionally formatted ranges.

Type: int

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.
typeintA FormatConditionType value. Type of conditional formatting.It could be one of the members of FormatConditionType.
operatorTypeintA 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
typeintA FormatConditionType value. The type of format condition.
operatorTypeintA 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
typeintA FormatConditionType value. Format condition type.

Returns: Formatting condition object index;

getCellArea(index)

Gets the conditional formatted cell range by index.

ParameterTypeDescription
indexintthe 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
indexintThe 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
startRowintThe startRow of the range.
startColumnintThe startColumn of the range.
totalRowsintThe number of rows of the range.
totalColumnsintThe number of columns of the range.

Returns: Returns TRUE, this FormatCondtionCollection should be removed.

removeCondition(index)

Removes the formatting condition by index.

ParameterTypeDescription
indexintThe index of the formatting condition to be removed.