日期:2014-05-19  浏览次数:20692 次

java读取Excel时出现读取到那一空列时,它把下一列的值给读取到上一列去了,请问这是什么愿因


见图:50列,第一列读的成功,读第二列为空,直接把下面列的值前移了。
我想知道为什么会出现HSSFCell对象为空的情况。怎么解决。

Iterator<HSSFCell> cit = (Iterator<HSSFCell>) row.cellIterator();
while(cit.hasNext())
{

HSSFCell cell = cit.next();

if (cell == null) {
break;
}

String strValue = parentReader.getCellValue(cell);


------解决方案--------------------
这个问题 我遇到过 给分就告诉你 哈哈
------解决方案--------------------
Java code

for(Row row : sheet) {
   for(int cn=0; cn<row.getLastCellNum(); cn++) {
       // If the cell is missing from the file, generate a blank one
       Cell cell = row.getCell(cn, MissingCellPolicy.CREATE_NULL_AS_BLANK);
       // Print the cell for debugging
       System.out.println("CELL: " + cn + " --> " + cell.toString());
   }
}