Apache POI 出现错误,无法读取使用 FileInputStream 传递的文件 [英] Getting error with Apache POI which is not able to read file passed using FileInputStream

查看:63
本文介绍了Apache POI 出现错误,无法读取使用 FileInputStream 传递的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在执行以下代码时,

FileInputStream fis = new FileInputStream("C:\\Users\\deepa\\Downloads\\TestDocument.xlsx");
        XSSFWorkbook workbook = new XSSFWorkbook(fis);

我收到错误

InputStream of class class org.apache.commons.compress.archivers.zip.ZipArchiveInputStream is not implementing InputStreamStatistics.

我已经包含了所有 apace poi jar 文件和 common -compress jar 文件.请帮忙.

I have included all the apace poi jar files and common -compress jar file. Please help.

推荐答案

不是任何类型的 Java 专家,但我使用 Selenium 进行测试自动化并且也遇到此错误.不知何故,我找到了一个解决方案:

Not a java expert of any sorts, but I use Selenium for test automation and was also getting this error. Somehow I found a solution:

  1. 使用文件编辑器打开 .classpath 文件.
  2. 剪切包含 commons-compress-1.18.jar 的 classpathentry 并将其粘贴到 classpathentry 下面的开头 kind="con"path="org.testng.TESTNG_CONTAINER"
  3. 保存并重试您的程序.

它解决了我的问题.抱歉,我无法解释原因(我不是真正的程序员).

It solved my problem. Sorry I can't explain why (I am not a real programmer).

这篇关于Apache POI 出现错误,无法读取使用 FileInputStream 传递的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆