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

    The top bottom rule checks whether the values in the top or bottom of a cell range match with the required values in the cell. In case the values don't match, the data is considered as invalid. This rule can be added using the methods of the ITop10 interface.

    The following options are available while adding top bottom rule in a worksheet:

    Refer to the following example code to add top bottom rule in a worksheet.

    Java
    Copy Code
    // Adding Top Bottom Rule
    Object[][] data=new Object[][] 
    {
        {1},
        {2},
        {3},
        {4},
        {5}
    };
    worksheet.getRange("A1:A5").setValue(data);
            
    ITop10 condition = worksheet.getRange("A1:A5").getFormatConditions().addTop10();
    condition.setTopBottom(TopBottom.Top);
    condition.setRank(50);
    condition.setPercent(true);
    condition.getInterior().setColor(Color.FromArgb(128,0,128));