# Expression Rule

Learn how to add an expression rule in conditional formatting using DsExcel with a sample code.

## Content

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](/document-solutions/dot-net-excel-api/api/online/DS.Documents.Excel/GrapeCity.Documents.Excel.IFormatCondition.html).
Refer to the following example code to add expression rule in a worksheet.

```csharp
// 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.FromArgb(255, 0, 0);
```