2012-07-17 173 views
3

我可以讀取Excel工作表逐列使用Apache POI ..?(不使用排迭代器)閱讀Excel工作表逐列使用Apache POI

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

我知道,上面的人會做同樣的。但是我需要在不使用Row Iterator的情況下獲得第一列的數據。

回答

8

您可以在紙張迭代,而無需使用迭代器

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 
    } 
相關問題