Apache POIparsing并处理空单元格

我正在使用java servletparsing上传的excel文件,

我得到的文件为inputstream,并制作工作簿,然后我想要循环虽然所有的单元格,包括空的,现在这是我在做什么,这将处理在数据中间的空单元格,但如果有一行是完全空的,然后是数据失败后的一行

for (int i = 0; i < mySheet.getPhysicalNumberOfRows(); i++) { Row row = mySheet.getRow(i); for (int j = 0; j < row.getPhysicalNumberOfCells(); j++) { Cell cell = row.getCell(j); } } 

所以这是我的行

 item item item //this row is empty item item item 

这是失败,我怎么处理这个?

谢谢您的帮助

如果行fectching并返回null,那么没有数据存储在该行的文件 – 它是完全空白的。

 for (int i = 0; i < mySheet.getPhysicalNumberOfRows(); i++) { Row row = mySheet.getRow(i); for (int c = row.getFirstCellNum(); c < row.getLastCellNum(); c++) { Cell cell = row.getCell(c); if (cell != null && cell.getCellType() != Cell.CELL_TYPE_BLANK) ..... } } 

并检查poi示例POI示例