5
votes

Can I read a excel sheet column wise using apache poi..?(without using row Iterator)

for (Row row : sheet) {
    Cell firstCell = row.getCell(0);
    // Printing Stuff
}

I know, the above one will do the same. But I need to get first column's data without using Row Iterator.

1

1 Answers

10
votes

You can iterate over the sheet without using iterator

    Workbook wb = WorkbookFactory.create(new FileInputStream("file.xls"));
    Sheet sheet = wb.getSheetAt(0);

    for (int j=0; j< sheet.getLastRowNum() + 1; j++) {
        Row row = sheet.getRow(j);
        Cell cell = row.getCell(0); //get first cell
        // Printing Stuff
    }