我可以使用apache poi读取excel表格列吗?(不使用行迭代器)
for (Row row : sheet) {
Cell firstCell = row.getCell(0);
// Printing Stuff
}
我知道,上面的也会这样做。但是我需要在不使用Row Iterator的情况下获得第一列的数据。
答案 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
}