Document Solutions for Excel, Java Edition | Document Solutions
Features / Worksheet / Range Operations / Access Cells, Rows and Columns in a Range
In This Topic
    Access Cells, Rows and Columns in a Range
    In This Topic

    You can access cells, rows and columns in a range by using the getCells method, the getRows method and the getColumns method of the IRange interface.

    Refer to the following example code in order to access cells, rows and columns in a worksheet.

    Java
    Copy Code
    // Create a new workbook and fetch the worksheet
    Workbook workbook = new Workbook();
    IWorksheet worksheet = workbook.getWorksheets().add();
            
    // Access Range and set A1:B5, C2:E4's interior color
    worksheet.getRange("A1:B5, C2:E4").getInterior().setColor(Color.GetGreen());
            
    // Access Rows and set row 1's font size
    worksheet.getRows().get(0).getFont().setSize(20);
            
    // Access Columns and delete column C
    worksheet.getColumns().get(2).delete();
            
    // Access Cells and set A1's value
    worksheet.getCells().get(0).setValue(1);