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

使用DefaultExcelReader导入遇到错误时报java.lang.NullPointerException #419

Open
fcmfcm01 opened this issue Mar 16, 2024 · 1 comment

Comments

@fcmfcm01
Copy link

fcmfcm01 commented Mar 16, 2024

Bug描述
版本:4.5.0
com.github.liaochong.myexcel.core.context.ReadContext#readConfig 未初始化,导致当Excel导入时对错误信息的处理失败。

Bug复现
按如下步骤复现(Steps to reproduce the behavior):

  1. 按照导入示例准备一份导入数据和POJO,其中导入数据中存在数字转换异常,例如,POJO中a 变量为Double型,数据中对应列数据为“字符”
  2. 使用DefaultExcelReader,导入刚才的数据, 得到下面的异常:
java.lang.NullPointerException: null
	at com.github.liaochong.myexcel.core.converter.ReadConverterContext.convert(ReadConverterContext.java:149)
	at com.github.liaochong.myexcel.core.DefaultExcelReader.lambda$instanceObj$18(DefaultExcelReader.java:432)
	at java.util.HashMap.forEach(HashMap.java:1289)
	at com.github.liaochong.myexcel.core.DefaultExcelReader.instanceObj(DefaultExcelReader.java:417)
	at com.github.liaochong.myexcel.core.DefaultExcelReader.getDataFromFile(DefaultExcelReader.java:329)
	at com.github.liaochong.myexcel.core.DefaultExcelReader.doRead(DefaultExcelReader.java:202)
	at com.github.liaochong.myexcel.core.DefaultExcelReader.read(DefaultExcelReader.java:183)
	at com.github.liaochong.myexcel.core.DefaultExcelReader.read(DefaultExcelReader.java:179)

期望的结果
Boolean toContinue = readContext.readConfig.exceptionFunction.apply(e, readContext); 语句能够正常执行

@fcmfcm01 fcmfcm01 changed the title Excel导入遇到错误时报java.lang.NullPointerException 使用DefaultExcelReader导入遇到错误时报java.lang.NullPointerException Mar 16, 2024
@liaochong
Copy link
Owner

请提供下版本,另外如果不导入图片,建议使用SaxExcelReader

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants