2016-01-06 24 views
1

我正在使用apache poi解析excel電子表格。根據poi iterator guide,行迭代器將跳過空行。我想迭代所有行,null或不。所以我用循環代替。如何迭代電子表格中的所有行(包括空值)

  Row row0 = sheet.getRow(0); 
      for (Row row : sheet) 
      { 
       rowIndex ++; 
       Cell cell = row.getCell(0); 
       if (cell != null) { 
        System.out.println(rowIndex); 
       } 
      } 

當我調試它在Eclipse中,以下表格,0行是空,但在for循環不爲空第一次迭代行。輸出(第一個不爲空單元格的行索引)應該是2,但它實際上打印1.

spreadsheet

debug in eclipse

爲什麼第一個空行的for循環跳過由?

回答

相關問題