空指针异常
cell.getStringCellValue();报空指针异常是为什么
cell.getStringCellValue();报空指针异常是为什么
2017-07-31
for (int i = 0; i <= lastRowNum+1; i++) {
HSSFRow row = sheet.getRow(i);
// 获取列数
int lastCellNum = row.getLastCellNum();
System.out.println("列数是:"+lastCellNum);
for (int j = 0; j <= lastCellNum+1; j++) {
HSSFCell cell = row.getCell(j);
String value = null;
if ((value=cell.getStringCellValue())!=null) {
System.out.print(value + " ");
}
else {
continue;
}
}
System.out.println("写出成功!");
}
你好,这是我写的代码,在cell.getStringCellValue();处也会报空指针异常,请问循环有什么错误呢
举报