# Average Rule

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

## Content





The average rule in conditional formatting can be added and deleted using the methods of the [IAboveAverage](/document-solutions/java-excel-api/api/online/com/grapecity/documents/excel/IAboveAverage.html) interface.

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

```Java
// Adding average rule
Workbook workbook = new Workbook();
IWorksheet worksheet = workbook.getWorksheets().get(0);
worksheet.getRange("A1").setValue(1);
worksheet.getRange("A2").setValue(2);
worksheet.getRange("A3").setValue(3);
worksheet.getRange("A4").setValue(4);
worksheet.getRange("A5").setValue(60000000);
        
IAboveAverage averageCondition = worksheet.getRange("A1:A5").getFormatConditions().addAboveAverage();
averageCondition.setAboveBelow(AboveBelow.AboveAverage); 
averageCondition.setNumStdDev(2);
averageCondition.setNumberFormat("0.00");
```