Java使用hutool工具类解析Excel,单元格空,赋值为空字符串
ExcelReader jobExcel = ExcelUtil.getReader(file.getInputStream(), 0);
Sheet sheet = jobExcel.getSheet();
int lastCellNum = sheet.getRow(Constants.EXCEL_READ_HEADER_ROW).getLastCellNum();
int rowCount = jobExcel.getRowCount();
for (int i = Constants.EXCEL_READ_ROW_VALUE; i < rowCount; i++) {
Row row = sheet.getRow(i);
for (int cellNum = 0; cellNum < lastCellNum; cellNum++) {
row.getCell(cellNum, Row.MissingCellPolicy.CREATE_NULL_AS_BLANK);
}
}
List<List<Object>> read = jobExcel.read(1);
Pom文件
<dependency>
<groupId>org.apache.poi</groupId>
<artifactId>poi-ooxml</artifactId>
<version>5.0.0</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.11</version>
</dependency>
|