Document Solutions for Excel, Java Edition | Document Solutions
Features / Conditional Formatting / Average Rule
In This Topic
    Average Rule
    In This Topic

    The average rule in conditional formatting can be added and deleted using the methods of the IAboveAverage interface.

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

    Java
    Copy Code
    // 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");