加载XSSFWorkbook类的Apache POI错误

时间:2021-07-19 20:24:59

I'm trying to write a program that works with Excel docs, but the HSSF format is too small for my requirements. I'm attempting to move to XSSF, but I keep getting errors when trying to use it.

我正在尝试编写一个与Excel文档一起使用的程序,但HSSF格式对于我的要求来说太小了。我正在尝试迁移到XSSF,但在尝试使用它时我一直遇到错误。

I managed to solve the first two by adding xmlbeans-2.3.0.jar and dom4j-1.6.jar to my program, but now this error is coming up, which doesn't seem to be resolved by adding the Apache commons jar available on the Apache website.

我设法通过将xmlbeans-2.3.0.jar和dom4j-1.6.jar添加到我的程序来解决前两个问题,但是现在出现了这个错误,这似乎没有通过添加Apache commons jar来解决Apache网站。

The error is as follows:

错误如下:

Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/commons/collections4/ListValuedMap
    at hot.memes.ExcelCreator.main(ExcelCreator.java:66)
Caused by: java.lang.ClassNotFoundException: org.apache.commons.collections4.ListValuedMap
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    ... 1 more

5 个解决方案

#1


34  

Add commons-collections4-x.x.jar file in your build path and try it again. It will work.

在构建路径中添加commons-collections4-x.x.jar文件并再次尝试。它会工作。

You can download it from https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.0

您可以从https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.0下载它

#2


18  

commons-collections4-x.x.jar definitely solve this problem but Apache has removed the Interface ListValuedMap from commons-Collections4-4.0.jar so use updated version 4.1 it has the required classes and Interfaces.

commons-collections4-x.x.jar肯定解决了这个问题,但是Apache已经从commons-Collections4-4.0.jar中删除了Interface ListValuedMap,所以使用更新版本4.1它具有所需的类和接口。

Refer here if you want to read Excel (2003 or 2007+) using java code.

如果您想使用Java代码阅读Excel(2003或2007+),请参阅此处。

http://www.codejava.net/coding/how-to-read-excel-files-in-java-using-apache-poi

#3


8  

Hurrah! Adding commons-collections jar files to my project resolved this problem. Two thumbs up to Lucky Sharma.

欢呼!将commons-collections jar文件添加到我的项目中解决了这个问题。两个赞许幸运夏尔马。

Solution: Add commons-collections4-4.1.jar file in your build path and try it again. It will work.

解决方案:在构建路径中添加commons-collections4-4.1.jar文件并再次尝试。它会工作。

You can download it from https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.1

您可以从https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.1下载它

#4


5  

Please note that 4.0 is not sufficient since ListValuedMap, was introduced in version 4.1.

请注意,自4.1版本中引入ListValuedMap以来,4.0是不够的。

You need to use this maven repository link for version 4.1. Replicated below for convenience

您需要使用此版本4.1的maven存储库链接。为方便起见,下面复制

 <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 -->
 <dependency>
   <groupId>org.apache.commons</groupId>
   <artifactId>commons-collections4</artifactId>
   <version>4.1</version>
</dependency>

#5


3  

Yeah, resolved the exception by adding commons-collections4-4.1 jar file to the CLASSPATH user varible of system. Downloaded from https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.1

是的,通过将commons-collections4-4.1 jar文件添加到CLASSPATH用户varible of system来解决异常。下载自https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.1

#1


34  

Add commons-collections4-x.x.jar file in your build path and try it again. It will work.

在构建路径中添加commons-collections4-x.x.jar文件并再次尝试。它会工作。

You can download it from https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.0

您可以从https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.0下载它

#2


18  

commons-collections4-x.x.jar definitely solve this problem but Apache has removed the Interface ListValuedMap from commons-Collections4-4.0.jar so use updated version 4.1 it has the required classes and Interfaces.

commons-collections4-x.x.jar肯定解决了这个问题,但是Apache已经从commons-Collections4-4.0.jar中删除了Interface ListValuedMap,所以使用更新版本4.1它具有所需的类和接口。

Refer here if you want to read Excel (2003 or 2007+) using java code.

如果您想使用Java代码阅读Excel(2003或2007+),请参阅此处。

http://www.codejava.net/coding/how-to-read-excel-files-in-java-using-apache-poi

#3


8  

Hurrah! Adding commons-collections jar files to my project resolved this problem. Two thumbs up to Lucky Sharma.

欢呼!将commons-collections jar文件添加到我的项目中解决了这个问题。两个赞许幸运夏尔马。

Solution: Add commons-collections4-4.1.jar file in your build path and try it again. It will work.

解决方案:在构建路径中添加commons-collections4-4.1.jar文件并再次尝试。它会工作。

You can download it from https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.1

您可以从https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.1下载它

#4


5  

Please note that 4.0 is not sufficient since ListValuedMap, was introduced in version 4.1.

请注意,自4.1版本中引入ListValuedMap以来,4.0是不够的。

You need to use this maven repository link for version 4.1. Replicated below for convenience

您需要使用此版本4.1的maven存储库链接。为方便起见,下面复制

 <!-- https://mvnrepository.com/artifact/org.apache.commons/commons-collections4 -->
 <dependency>
   <groupId>org.apache.commons</groupId>
   <artifactId>commons-collections4</artifactId>
   <version>4.1</version>
</dependency>

#5


3  

Yeah, resolved the exception by adding commons-collections4-4.1 jar file to the CLASSPATH user varible of system. Downloaded from https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.1

是的,通过将commons-collections4-4.1 jar文件添加到CLASSPATH用户varible of system来解决异常。下载自https://mvnrepository.com/artifact/org.apache.commons/commons-collections4/4.1