• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Java API for MS Excel 2010

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi, could anyone tell me about a Java API which can extract data from an excel in MS-EXCEL 2010 format .
The poi apis (HSSF and XSSF) aren't working for me (.xlsx 2010 format).

Regards
RajHans
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Not nearly enough drivel to qualify for Meaningless Drivel. The question looks meaningful, too. Let's move it to a less exalted forum...
 
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What does "aren't working for me" mean? Post the code you're using. POI in general is capable of working with XLSX files.
 
RajHans Kumar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The piece of code is given below --


It throws an error

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:149)
at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:136)
at org.apache.poi.openxml4j.opc.Package.<init>(Package.java:54)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:81)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:220)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:39)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:186)

at the line of code XSSFWorkbook workbook = new XSSFWorkbook(fis);

I have tried putting the appropriate poi jars in the build path.Still,I am getting such exceptions.
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The build path isn't used when running a program; you need to add all the jars to the classpath used at runtime.
 
RajHans Kumar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have added all the jars in the classpath ,however still this exception

Exception in thread "AWT-EventQueue-0" java.lang.NoClassDefFoundError: org/dom4j/DocumentException
at org.apache.poi.openxml4j.opc.OPCPackage.init(OPCPackage.java:149)
at org.apache.poi.openxml4j.opc.OPCPackage.<init>(OPCPackage.java:136)
at org.apache.poi.openxml4j.opc.Package.<init>(Package.java:54)
at org.apache.poi.openxml4j.opc.ZipPackage.<init>(ZipPackage.java:81)
at org.apache.poi.openxml4j.opc.OPCPackage.open(OPCPackage.java:220)
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:39)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:186)

For this line of code:-
XSSFWorkbook workbook = new XSSFWorkbook(fis);
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Apparently not.
 
RajHans Kumar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi
I have used the following jars
dom4j-full.jar
ooxml-schemas-1.0.jar
poi3.7-20101029.jar
poi-examples-3.7-20101029
poi-ooxml-schemas-3.7-20101029
poi-scratchpad-3.7-20101029
xmlbeans-2.3.0.jar

The CLASSPATH is as follows
D:\toold\poi-3.7-20101029;D:\toold\poi-ooxml-3.5-FINAL.jar;D:\toold\dom4j-full.jar;D:\toold\poi-3.7\dom4j-full.jar;D:\toold\poi-3.7\ooxml-schemas-1.0.jar;D:\toold\poi-3.7\poi3.7-20101029.jar;D:\toold\poi-3.7\poi-examples-3.7-20101029;D:\toold\poi-3.7\poi-ooxml-schemas-3.7-20101029;D:\toold\poi-3.7\poi-scratchpad-3.7-20101029;D:\toold\xmlbeans-2.3.0.jar
as given in the Environment Variable in the User Variables section.
 
RajHans Kumar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there anyother Jar needed ?
Is the classpath correct ?
 
Ulf Dittmer
Rancher
Posts: 43081
77
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

D:\Sriraj\Santander\toold\poi-3.7-20101029


That's not a file.

D:\Sriraj\Santander\toold\poi-ooxml-3.5-FINAL.jar


You should use files that go together - don't mix 3.5 libs with 3.7 libs.

D:\Sriraj\Santander\toold\dom4j-full.jar
D:\Sriraj\Santander\toold\poi-3.7\dom4j-full.jar


Including the same file twice is a bad idea. That's also not the file shipped with POI; why are you using a different one?

D:\Sriraj\Santander\toold\poi-3.7\ooxml-schemas-1.0.jar


That looks outdated; it certainly isn't shipped with current POI versions. See the above comment about not mixing versioned libs.

D:\Sriraj\Santander\toold\poi-3.7\poi3.7-20101029.jar


That looks OK.

D:\Sriraj\Santander\toold\poi-3.7\poi-examples-3.7-20101029


That's not a file, either. (It's also examples that aren't generally used if you run your code.)

D:\Sriraj\Santander\toold\poi-3.7\poi-ooxml-schemas-3.7-20101029


Nor is this.

D:\Sriraj\Santander\toold\poi-3.7\poi-scratchpad-3.7-20101029


Or this.

D:\Sriraj\Santander\toold\xmlbeans-2.3.0.jar


I'm not sure if that's needed, but it probably can't hurt.
 
RajHans Kumar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks a lot
That was silly
Now I have updated as per the comments and my classpath is
D:\toold\poi-jars\dom4j-1.6.1.jar;D:\toold\poi-jars\geronimo-stax-api_1.0_spec-1.0.jar;D:\toold\poi-jars\xmlbeans-2.3.0.jar;D:\toold\poi-jars\poi-ooxml-3.7-20101029.jar;D:\toold\poi-jars\poi-ooxml-schemas-3.7-20101029.jar;D:\toold\poi-jars\poi-scratchpad-3.7-20101029.jar;D:\toold\poi-jars\poi-3.7-20101029.jar;D:\toold\poi-jars\poi-examples-3.7-20101029.jar

I am still getting an exception
org.apache.poi.POIXMLException: org.apache.poi.openxml4j.exceptions.InvalidFormatException: Package should contain a content type part [M1.13]
at org.apache.poi.util.PackageHelper.open(PackageHelper.java:41)
at org.apache.poi.xssf.usermodel.XSSFWorkbook.<init>(XSSFWorkbook.java:186)
 
RajHans Kumar
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Any idea about this exception ?
 
Yes, my master! Here is the tiny ad you asked for:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic