[]
Adds a new conditional format.
Creates a conditional formatting rule of the specified type and adds it to this collection.
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
| 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 |
| object | formula2 | Specifies the second formula of the conditional format. For Between and NotBetween, this value must not be |
| Type | Description |
|---|---|
| object | The new conditional format. |
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;
| Type | Condition |
|---|---|
| ArgumentNullException | if required arguments are missing for the specified conditional format type. |
| NotSupportedException | if |