Documents for Excel .NET Edition | GCDocuments
Features / Conditional Formatting / Cell Value Rule
In This Topic
    Cell Value Rule
    In This Topic

    The cell value rule compares values entered in the cells with the condition specified in the conditional formatting rule. In order to add a cell value rule, you can use the Formula1 property and Formula2 property of the IFormatCondition interface. You can also use the Operator property of the IFormatCondition interface to set the operator that will perform the comparison operation, like "Between", "Less Than" etc.

    Refer to the following example code to add cell value rule to a range of cells in a worksheet.

    Copy Code
    // Assigning value using object 
    worksheet.Range["A1:A5"].Value = new object[,]
    // Defining format rules.
    IFormatCondition condition = worksheet.Range["A1:A5"].FormatConditions.Add(FormatConditionType.CellValue, FormatConditionOperator.Between, 1, 5) as IFormatCondition;
    condition.NumberFormat = "0.000";