[]
        
(Showing Draft Content)

GrapeCity.Documents.Excel.IFormatConditions.Add

Add Method

Add(FormatConditionType, FormatConditionOperator, object, object)

Adds a new conditional format.

Creates a conditional formatting rule of the specified type and adds it to this collection.

Declaration
object Add(FormatConditionType type, FormatConditionOperator formatConditionOperator = FormatConditionOperator.Between, object formula1 = null, object formula2 = null)
Function Add(type As FormatConditionType, Optional formatConditionOperator As FormatConditionOperator = FormatConditionOperator.Between, Optional formula1 As Object = Nothing, Optional formula2 As Object = Nothing) As Object
Parameters
Type Name Description
FormatConditionType type

Specifies the type for the new conditional format.

FormatConditionOperator formatConditionOperator

Specifies the operator of the conditional format. For CellValue, this value must not be None.

object formula1

Specifies the first formula of the conditional format. For CellValue, this value must not be null.

object formula2

Specifies the second formula of the conditional format. For Between and NotBetween, this value must not be null.

Returns
Type Description
object

The new conditional format.

Examples
IRange range = worksheet.Range["A1:A5"];
range.Value = new object[,] {{1}, {3}, {5}, {7}, {9}};
object condition = range.FormatConditions.Add(
    FormatConditionType.CellValue,
    FormatConditionOperator.Between,
    1,
    5
);
((IFormatCondition)condition).Interior.Color = Color.Yellow;
Exceptions
Type Condition
ArgumentNullException

if required arguments are missing for the specified conditional format type.

NotSupportedException

if formula1 or formula2 uses an unsupported table formula or reference formula.