poi导入excel,循环读取数据时,读到第10行,就显示单元格的值是空字符串,实际是有值的。只能读到前几行,包括10行以后的数据都读不到。
代码:
问题相关代码
for (int i = 3; i < lastRowNum; i++) {
Row row = sheet.getRow(i); // 当i=9 ,也就是excel里第10行,yearMonth=“”
//申报年月
String yearMonth = row.getCell(1).getStringCellValue(); // yearMonth取不到值
String retyearMonth = null;
if (null == yearMonth || "".equals(yearMonth)) {
error.append("\n第" + (i + 1) + "行,申报年月为空");
return error.toString();
} else {
retyearMonth = yearMonth.substring(0, 4) + "-" + yearMonth.substring(4, 6);
}
}
前面的行都可以读到