读书人

java读取Excel时出现读取到那一空列时

发布时间: 2012-08-30 09:55:54 作者: rapoo

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());   }} 

读书人网 >J2EE开发

热点推荐