# Cell Value Rule

In DsExcel, you can easily add or remove the cell value rule in conditional formatting. Learn more in DsExcel docs.

## Content





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 [setNumberFormat](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IFormatCondition.html#setNumberFormat) method of the [IFormatCondition](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IFormatCondition.html) 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.

```Java
// Assigning values using Object 
Object[][] data = new Object[][] 
{ 
    { 1 }, 
    { 3 }, 
    { 5 }, 
    { 7 }, 
    { 9 } 
};
worksheet.getRange("A1:A5").setValue(data);
        
// Defining the Cell Value Rule
IFormatCondition condition = 
(IFormatCondition) worksheet.getRange("A1:A5").getFormatConditions().add(FormatConditionType.
CellValue, FormatConditionOperator.Between, 1, 5);
        
condition.setNumberFormat("0.000");
```