Getting error with Apache POI which is not able to

2019-07-20 13:01发布

问题:

While executing below code,

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

I am getting error as

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

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

回答1:

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. Open the .classpath file with a file editor.
  2. Cut your classpathentry that contains commons-compress-1.18.jar and paste it at the beginning below classpathentry kind="con"path="org.testng.TESTNG_CONTAINER"
  3. Save and retry your program.

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