• 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

Apache POI, FormFile, and XSSF

 
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having some major difficulty here that I'm hoping someone can help me with. I've googled my brains out trying to find an answer that works, and am having no success. We are now standardized at Excel 2007 and our users want to not have to save the files as 97-2003 format just to read the file. The problem I'm having is that I'm using the apache struts FormFile. XSSF does not care for the InputStream with FormFile. I've tried creating a new FileInputStream using the full path (I extract that prior to uploading so that it's part of the ActionForm) and using the full path (which includes the filename) for creating the new Workbook. I've tried a variety of things, including using the WorkbookFactory. I'm at a loss. Everthing I see says it tells you how to read a 2007 Excel file, but all of their examples are for ".xls" files. I have no doubt they work, but I would like to see something for 2007+ format.

Here's the code:



Maybe I missed something, but I'm now pounding my head against a brick wall. This is my umpteenth iteration at trying something to make this work. I appreciate any information that may help. I'm willing to try anything, including standing on my head reciting Shakespeare. If that works, I'll take it.

Pat Flickner
 
Pat Flickner
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
By the way, I'm using eclipse Helios release 2 with the WebSphere jdk. I get the following error:

 
Pat Flickner
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I added the dom4j.jar to my classpath (found that somewhere, figured I'd try it) and now I'm getting "org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException". Am I missing a jar or something? Here's what I have besides my spring and struts jars:

<classpathentry kind="lib" path="Web Content/WEB-INF/lib/commons-beanutils-1.8.0.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/commons-collections-3.2.1.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/commons-dbcp-1.2.2.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/commons-digester-2.1.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/commons-fileupload-1.2.1.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/commons-io-1.4.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/commons-jexl-2.0.1.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/commons-lang-2.4.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/commons-logging-1.1.1.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/commons-logging-adapters-1.1.1.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/commons-logging-api-1.1.1.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/commons-pool-1.4.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/commons-validator-1.3.1.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/dom4j-full.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/junit-3.8.1.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/jxls-core-1.0-RC-2.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/jxls-reader-1.0-RC-2.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/log4j-1.2.16.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/ooxml-schemas-1.1.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/poi-3.7-20101029.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/poi-ooxml-3.7-20101029.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/poi-ooxml-schemas-3.7-20101029.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/poi-scratchpad-3.7-20101029.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/xbean.jar"/>

I figue if I'm now getting another message, I must be missing something, or something I have is too old (or new) for the processes.
 
Marshal
Posts: 28177
95
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yes, I expect you are missing one of the required jars. I know I had to go through that cycle a couple of times. The stack trace you got (but didn't post) should contain useful information about what that exception was all about.
 
Pat Flickner
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wish. I looked at the list of jar files I'm supposed to have on the Apache site and even added a few (like the dom4j.jar file - that isn't on the list). I'm getting a org.apache.poi.POIXMLException error: org.apache.poi.POIXMLException: java.lang.reflect.InvocationTargetException. The stack trace is null. There is no other information and it's driving me crazy. The only thing I don't have is thte xmlbean jar. I think that's right. I will try adding that and see if that works. It's the only thing I haven't tried (just came across that).
 
Pat Flickner
Ranch Hand
Posts: 173
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


SON OF A GUN!!! That did it. Here's my final portion (I actually had the xbean.jar (and possibly an older version that the one I downloaded and replaced it with), but I was missing the other things that were in the lib:

<classpathentry kind="lib" path="Web Content/WEB-INF/lib/jsr173_1.0_api.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/resolver.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/xbean_xpath.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/xmlbeans-qname.jar"/>
<classpathentry kind="lib" path="Web Content/WEB-INF/lib/xmlpublic.jar"/>


That did it! I added the other ones and I can now read xlsx files. Now I can play. YAY!
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic