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

时间:2012-07-17 07:17:59

标签: java apache-poi

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

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

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

1 个答案:

答案 0 :(得分: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
    }