Browse Source

修复xls直接读取第2页 `NPE` 的bug #1280

pull/1391/head
Jiaju Zhuang 5 years ago
parent
commit
927f6b410f
  1. 7
      src/main/java/com/alibaba/excel/analysis/v03/handlers/BofRecordHandler.java
  2. 4
      src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java
  3. 1
      update.md

7
src/main/java/com/alibaba/excel/analysis/v03/handlers/BofRecordHandler.java

@ -38,14 +38,15 @@ public class BofRecordHandler extends AbstractXlsRecordHandler {
readSheetIndex = 0;
xlsReadWorkbookHolder.setReadSheetIndex(readSheetIndex);
}
ReadSheet readSheet = xlsReadWorkbookHolder.getActualSheetDataList().get(readSheetIndex);
assert readSheet != null : "Can't find the sheet.";
ReadSheet actualReadSheet = xlsReadWorkbookHolder.getActualSheetDataList().get(readSheetIndex);
assert actualReadSheet != null : "Can't find the sheet.";
// Copy the parameter to the current sheet
readSheet = SheetUtils.match(readSheet, xlsReadContext);
ReadSheet readSheet = SheetUtils.match(actualReadSheet, xlsReadContext);
if (readSheet != null) {
xlsReadContext.currentSheet(readSheet);
xlsReadContext.xlsReadSheetHolder().setIgnoreRecord(Boolean.FALSE);
} else {
xlsReadContext.currentSheet(actualReadSheet);
xlsReadContext.xlsReadSheetHolder().setIgnoreRecord(Boolean.TRUE);
}
// Go read the next one

4
src/test/java/com/alibaba/easyexcel/test/temp/Lock2Test.java

@ -32,9 +32,9 @@ public class Lock2Test {
@Test
public void test() throws Exception {
File file = TestFileUtil.readUserHomeFile("test/test4.xlsx");
File file = TestFileUtil.readUserHomeFile("test/test6.xls");
List<Object> list = EasyExcel.read(file).sheet().headRowNumber(0).doReadSync();
List<Object> list = EasyExcel.read(file).sheet(1).headRowNumber(0).doReadSync();
LOGGER.info("数据:{}", list.size());
for (Object data : list) {
LOGGER.info("返回数据:{}", JSON.toJSONString(data));

1
update.md

@ -6,6 +6,7 @@
* 修复多个`sheet`不按照顺序写入 会乱序的bug [Issue #1332](https://github.com/alibaba/easyexcel/issues/1332)
* 修改head是List时,内容单元格的样式不生效 [Issue #1339](https://github.com/alibaba/easyexcel/issues/1339)
* 修复xls仅公式行 不读取的bug [Issue #1324](https://github.com/alibaba/easyexcel/issues/1324)
* 修复xls直接读取第2页 `NPE` 的bug [Issue #1280](https://github.com/alibaba/easyexcel/issues/1280)
# 2.2.3

Loading…
Cancel
Save