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

上传excel并读取遇到的问题 #215

Closed
hzqgit opened this issue Jan 14, 2019 · 2 comments
Closed

上传excel并读取遇到的问题 #215

hzqgit opened this issue Jan 14, 2019 · 2 comments

Comments

@hzqgit
Copy link

hzqgit commented Jan 14, 2019

做excel上传的时候,流是获取到了,但是在
public static ExcelTypeEnum valueOf(InputStream inputStream){
try {
if (!inputStream.markSupported()) {
return null;
}
FileMagic fileMagic = FileMagic.valueOf(inputStream);
if(FileMagic.OLE2.equals(fileMagic)){
return XLS;
}
if(FileMagic.OOXML.equals(fileMagic)){
return XLSX;
}
return null;
} catch (IOException e) {
throw new RuntimeException(e);
}
}

inputStream.markSupported中报错,返回的为false,我上传的文件是xlsx类型的,确认没问题,看源码发现作者把值设为了true,我这边改不了源码,求解

@hzqgit
Copy link
Author

hzqgit commented Jan 15, 2019

问题解决了,文件流还要转成buffer,
inputStream = new BufferedInputStream(file.getInputStream());
建议作者在读取的时候标注下inputStream的类型,以免引起混淆。
EasyExcelFactory.read(inputStream, new Sheet(1, 1, Model.class));

@zhuangjiaju
Copy link
Collaborator

新版本 可以不用这个。遇到这个问题建议升级版本

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