Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Apache POI error loading XSSFWorkbook class

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.

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.

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 
like image 748
Cameron Zach Avatar asked Sep 23 '16 22:09

Cameron Zach


People also ask

What is XSSFWorkbook in Java?

XSSFWorkbook − This class has methods to read and write Microsoft Excel and OpenOffice xml files in . xls or . xlsx format. It is compatible with MS-Office versions 2007 or later.

Do we need to close XSSFWorkbook?

Constructs a XSSFWorkbook object from a given file. Once you have finished working with the Workbook, you should close the package by calling close() , to avoid leaving file handles open.

What is XSSF and HSSF?

Overview. HSSF is the POI Project's pure Java implementation of the Excel '97(-2007) file format. XSSF is the POI Project's pure Java implementation of the Excel 2007 OOXML (. xlsx) file format. HSSF and XSSF provides ways to read spreadsheets create, modify, read and write XLS spreadsheets.

What is XSSF function?

The XSSF library implementation should be used for Excel . xlsx file format. The HSSF library and XSSF API provides mechanisms to read, write or modify excel spreadsheets. It also provides SXSSF that is an extension of XSSF to work with very large excel sheets.


1 Answers

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

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

like image 187
Lakhwinder Sharma Avatar answered Oct 14 '22 20:10

Lakhwinder Sharma