Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

不能和原来的版本一样,直接读取指定的sheet。 #772

Closed
dongjun613 opened this issue Oct 29, 2019 · 8 comments
Closed

不能和原来的版本一样,直接读取指定的sheet。 #772

dongjun613 opened this issue Oct 29, 2019 · 8 comments
Assignees
Labels
bug Something isn't working question Further information is requested

Comments

@dongjun613
Copy link

触发场景描述
比如一个excel有5个sheet,我想直接读取第二个,这时候会报空指针
触发Bug的代码

   TestListener listener = new TestListener();
        //EasyExcel.read(fileName, listener).sheet(1).headRowNumber(0).doRead();
        ExcelReader excelReader = EasyExcel.read(fileName).build();
        ReadSheet readSheet =
                EasyExcel.readSheet(1, "Sheet1").registerReadListener(listener).build();
        //List<ReadSheet> readSheets = excelReader.excelExecutor().sheetList();
        //excelReader.read(readSheets);
        excelReader.read(readSheet);
        excelReader.finish();

提示的异常或者没有达到的效果
Exception in thread "main" java.lang.NullPointerException
at com.alibaba.excel.analysis.v03.handlers.BofRecordHandler.processRecord(BofRecordHandler.java:78)
at com.alibaba.excel.analysis.v03.XlsSaxAnalyser.processRecord(XlsSaxAnalyser.java:138)
at org.apache.poi.hssf.eventusermodel.MissingRecordAwareHSSFListener.processRecord(MissingRecordAwareHSSFListener.java:203)
at org.apache.poi.hssf.eventusermodel.FormatTrackingHSSFListener.processRecord(FormatTrackingHSSFListener.java:92)
at org.apache.poi.hssf.eventusermodel.HSSFRequest.processRecord(HSSFRequest.java:109)
at org.apache.poi.hssf.eventusermodel.HSSFEventFactory.genericProcessEvents(HSSFEventFactory.java:179)
at org.apache.poi.hssf.eventusermodel.HSSFEventFactory.processEvents(HSSFEventFactory.java:136)
at org.apache.poi.hssf.eventusermodel.HSSFEventFactory.processWorkbookEvents(HSSFEventFactory.java:82)
at org.apache.poi.hssf.eventusermodel.HSSFEventFactory.processWorkbookEvents(HSSFEventFactory.java:54)
at com.alibaba.excel.analysis.v03.XlsSaxAnalyser.execute(XlsSaxAnalyser.java:110)
at com.alibaba.excel.analysis.ExcelAnalyserImpl.analysis(ExcelAnalyserImpl.java:104)
at com.alibaba.excel.ExcelReader.read(ExcelReader.java:185)
at com.alibaba.excel.ExcelReader.read(ExcelReader.java:174)
at cn.pelerin.bfanalyze.common.EasyExcelTest.easyExcel(EasyExcelTest.java:28)
at cn.pelerin.bfanalyze.common.EasyExcelTest.main(EasyExcelTest.java:16)

@dongjun613 dongjun613 added the bug Something isn't working label Oct 29, 2019
@dongjun613 dongjun613 changed the title 不能和原来的版本一下,直接读取指定的sheet。 不能和原来的版本一样,直接读取指定的sheet。 Oct 29, 2019
@zhuangjiaju
Copy link
Collaborator

请提提供版本号。或者尝试升级到2.1.0-beat4

@zhuangjiaju zhuangjiaju added the question Further information is requested label Oct 29, 2019
@dongjun613
Copy link
Author

dongjun613 commented Oct 30, 2019

请提提供版本号。或者尝试升级到2.1.0-beat4

使用的就是最新版2.1.0-beat4,现在如果要读取第二个sheet,必须先读取第一个才行。

public ExcelReader read(List<ReadSheet> readSheetList) {
        checkFinished();
        excelAnalyser.analysis(readSheetList, Boolean.FALSE);
        return this;
    }
List<ReadSheet> readSheets = Lists.newArrayList();
        readSheets.add(readSheet1);
        readSheets.add(readSheet2);
        excelReader.read(readSheets);
        //或者
        excelReader.read(readSheet1, readSheet2);

现在只能这样去获取。

@zhuangjiaju
Copy link
Collaborator

这个已经在2.1.1里面修复,非常感谢您的意见。

@aishuohuadebenrenyi
Copy link

我用的2.2.0-beta1版本,还是报空指针错误。请问,有什么办法解决吗?

@vito16
Copy link

vito16 commented Jun 3, 2020

2.2.3版本还是有该错误。
换到2.1.7能正常使用。
也是指定了sheet下标来读取。
@zhuangjiaju

@mingyujiao
Copy link

读取 07版本的没问题,但是 03 版本的还是空指针错误

@shenhuaxin
Copy link

shenhuaxin commented Jun 24, 2020

读取 07版本的没问题,但是 03 版本的还是空指针错误

我也遇到了,指定sheetName就会报空指针, sheet()则不会, 希望能解决一下, 版本为2.2.5

@DLW59
Copy link

DLW59 commented Jun 25, 2020

2.2.4版本也有此问题,03版本就会

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

7 participants