my dog learned polymorphism*
The moose likes Other JSE/JEE APIs and the fly likes Converting Old POI Reading .xls Files to POI 3.7 Issues Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Other JSE/JEE APIs
Bookmark "Converting Old POI Reading .xls Files to POI 3.7 Issues" Watch "Converting Old POI Reading .xls Files to POI 3.7 Issues" New topic
Author

Converting Old POI Reading .xls Files to POI 3.7 Issues

Pat Flickner
Ranch Hand

Joined: Nov 17, 2003
Posts: 173
I am having difficulty moving to the new process. I didn't have to change much using POI 3.7 (just removed the (short) casting) to replace the deprecated with the new methods, like row.getCell(). Yet, on the Busy Developer's Guide to HSSF and XSSF Features (http://www.coderanch.com/forums/jforum?module=posts&action=insert&forum_id=45 ), it shows the deprecated values.

Anyway, when I upload a 97-2003 format spreadsheet (xls), I am erroring out on the line . It doesn't even hit the catch, just goes straight to an error with the explanation
Caused by: java.lang.NoSuchMethodError: org/apache/poi/hssf/usermodel/HSSFRow.getCell(I)Lorg/apache/poi/hssf/usermodel/HSSFCell;
followed by
javax.servlet.ServletException: org/apache/poi/hssf/usermodel/HSSFRow.getCell(I)Lorg/apache/poi/hssf/usermodel/HSSFCell;
.

The reason I bring this up is because I was converting to use 2007+ .xlsx format spreadsheets and I was getting strange errors uploading those (and this got caught in the try/catch):
Unable to process spreadsheet: Invalid header signature; read 1688935826934608, expected -2226271756974174256
.

When I looked up the error, everything said you had to update to POI 3.5 or later (I have 3.7), so I'm stumped. By both errors, actually. I stripped all formatting just to be certain that there was nothing funny in the spreadsheets that couldn't be handled. Help.


Pat Flickner
Ranch Hand

Joined: Nov 17, 2003
Posts: 173
(By the way, I did try using XSSF as well - wasn't much better)
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42277
    
  64
Make sure your code compiles against POI 3.7, and that the same libraries are used for compilation and at runtime. In general, upgrading POI is smooth, but sometimes methods get reorganised between releases.


Ping & DNS - my free Android networking tools app
Pat Flickner
Ranch Hand

Joined: Nov 17, 2003
Posts: 173
Exactly what do you mean
Make sure your code compiles against POI 3.7, and that the same libraries are used for compilation and at runtime.


I pulled in the jars, recompiled my entire application, and made the changes to replace the deprecated methods, and then ran it. I'm no newbie, just looking to find out why I'm having issues.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

So that takes care of reviewing the compiling environment. Now you've got your runtime environment to review, which appears to be a servlet container of some kind. It's possible that your effective classpath includes two different copies of the POI jar, at least that's one possibility based on the error message. Did you put the POI jar in the container's classpath and in your application's WEB-INF/lib, for example?
Pat Flickner
Ranch Hand

Joined: Nov 17, 2003
Posts: 173
Nope. Unfortunately, I removed all of the old and put in all of the new. Next?
Pat Flickner
Ranch Hand

Joined: Nov 17, 2003
Posts: 173
And I just realized that sounded snarky. It wasn't. I've checked everything and can't figure out why the new stuff breaks.
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18657
    
    8

And which jar file is the HSSFRow class being loaded from in the environment where the error occurs?

Hint:
Pat Flickner
Ranch Hand

Joined: Nov 17, 2003
Posts: 173
poi-3.7-20101029.jar
and I'm using tomcat 5.5 on eclipse ganymede - no jars except jconn3.jar, tools.jar, and bootstrap.jar are part of the global environment
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Converting Old POI Reading .xls Files to POI 3.7 Issues