Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reading Excel sheet column wise using apache poi

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.

like image 928
Ramkumar Kalirajan Avatar asked Jul 17 '12 07:07

Ramkumar Kalirajan


1 Answers

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
    }
like image 170
gresdiplitude Avatar answered Nov 17 '22 09:11

gresdiplitude