The expression rule in conditional formatting is used to set the expression rule's formula. This rule can be added using the properties and methods of the IFormatCondition interface.
Refer to the following example code to add expression rule in a worksheet.
C# |
Copy Code |
---|---|
// Adding Expression Rule worksheet.Range["A1:B5"].Value = new object[,] { {1, 2}, {0, 1}, {0, 0}, {0, 3}, {4, 5} }; IFormatCondition condition = worksheet.Range["B1:B5"].FormatConditions.Add(FormatConditionType.Expression, 0, "=A1") as IFormatCondition; condition.Interior.Color = Color.FromRGB(255, 0, 0); |