简体   繁体   中英

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.

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
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM