File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Parsing Excel-2007-Format (xlsx) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Parsing Excel-2007-Format (xlsx)" Watch "Parsing Excel-2007-Format (xlsx)" New topic
Author

Parsing Excel-2007-Format (xlsx)

Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

Hi
I want to read data from Excel-2007-Format (xlsx) and store it in Data base, i try to use JXL but it not support this Excel-2007 and i also try to read it through Apachi POI API but i not find any proper solutions.


please any body have any idea about this help me








Eduardo Bueno
Ranch Hand

Joined: Jun 04, 2009
Posts: 155
What did you go through in Apache POI?

You can read a .xlsx file with POI 3.5+ using a WorkbookFactory.

http://poi.apache.org/spreadsheet/quick-guide.html#ReadWriteWorkbook
Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

which jar i used for this? currently i used POI = poi-ooxml-3.5-beta5.jar and poi-scratchpad-3.2-FINAL file
Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

i try to this code but it gives errors





java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Workbook
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
Exception in thread "main"
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41078
    
  43
which jar i used for this? currently i used POI = poi-ooxml-3.5-beta5.jar and poi-scratchpad-3.2-FINAL file

Don't use any of the 3.2 files; use the 3.5 files.


Ping & DNS - my free Android networking tools app
Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

thnx Ulf Dittmer,
i change the All jars to 3.5beta5 but same error again.............
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41078
    
  43
Maybe there's a typo somewhere? I found that class in a file called poi-3.5-beta6-20090622.jar (but I *think* it was there even in 3.5 beta 5).

Which command, exactly, are you using to execute the code?
Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

i run it from myEclipse through main method
Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

can you tell me please which jars working fine for this purpose because i try all 3.5 beta5 but i could not got my result,
i m very thank to you if i do this with yous helps
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41078
    
  43
Well, I could download 3.5 beta 5 to see if the class is in there, but since it's your problem I'll let you download 3.5 beta 6 instead; that has the class for sure. If you then still experience the problem it's an issue of setting the classpath incorrectly.
Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

Ulf Dittmer,

i use these files poi-ooxml-3.5-beta6-20090522,poi-scratchpad-3.5-beta6-20090222,poi-contrib-3.5-beta6-20090222

in this package org.apache.poi.ss.usermodel only one class show WorkbookFactory; Workbook class not in this package

but still problem error is

java.lang.NoClassDefFoundError: org/apache/poi/ss/usermodel/Workbook
at java.lang.ClassLoader.defineClass1(Native Method)
at java.lang.ClassLoader.defineClass(ClassLoader.java:620)
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:124)
at java.net.URLClassLoader.defineClass(URLClassLoader.java:260)
at java.net.URLClassLoader.access$000(URLClassLoader.java:56)
at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:276)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
Exception in thread "main"
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41078
    
  43
You're missing the file I mentioned above, which is called poi-3.5-beta6-20090622.jar. (You most likely don't need the contrib file, but it doesn't hurt to have it in the classpath.)
Mark Kafe
Ranch Hand

Joined: Jun 23, 2008
Posts: 60

thnx Ulf Dittmer
now its working when i add this file
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Parsing Excel-2007-Format (xlsx)
 
Similar Threads
Reduce Excel XML file size
Hash value are not same
How to read xlsx file from local java file
Excel conversion tool.
read an excel file in .xlsx format