首页 文章

使用apache poi明智地阅读Excel工作表列

提问于
浏览
3

我可以使用apache poi读取excel表格列吗?(不使用行迭代器)

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

我知道,上面的也会这样做 . 但是我需要在不使用Row Iterator的情况下获得第一列的数据 .

1 回答

  • 9

    您可以在不使用迭代器的情况下迭代工作表

    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
        }
    

相关问题