3

Problem reading Excel 2007 file .xlsx file extention, while I am trying to read with apache poi:

InputStream file = new FileInputStream(C:\\test.xlsx);

---> XSSFWorkbook workbook = new XSSFWorkbook(file);

This line giving me an exception Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlbeans/XmlObject please, what can be cause of this error?

Brian Agnew
  • 268,207
  • 37
  • 334
  • 440
Olzhas
  • 235
  • 2
  • 7
  • 21

5 Answers5

14

you need to include a jar file named xmlbeans-x.x.x.jar that comes under folder "your_location_of_poi\poi-x.x\ooxml-lib\" in your classpath.

Note: x.x is the version of poi that you are using and x.x.x is the version number of that jar file under the above mentioned folder

Abubakkar
  • 15,488
  • 8
  • 55
  • 83
  • you can download that jar file from here http://www.java2s.com/Code/Jar/x/Downloadxmlbeansjar.htm by the way. Scroll down for other versions. – Marius Feb 12 '15 at 10:39
  • I am using a Linux virtual machine where Office is not installed. I have created a Swing Application for Excel reading. The app works fine in Windows but giving java.lang.ClassNotFoundException: org.apache.xmlbeans.XmlException on Linux VM. – iltaf khalid Feb 02 '16 at 10:06
2

You download extra jar file. You can download :

http://www.findjar.com/index.x;jsessionid=D9C61BD4B98370C199118B8C53CC689F?query=org.apache.xmlbeans.XmlObject

katsu
  • 558
  • 1
  • 7
  • 20
1

You're missing the extra jar files that come with POI. Include them in your classpath.

awm
  • 2,723
  • 2
  • 18
  • 26
0

You don't have XMLBeans in your classpath.

Dan D.
  • 32,246
  • 5
  • 63
  • 79
0

I downloaded xmlbeans.jar and added to Library as External Jar. It resolved my issue.

Ramesh
  • 1