aspose file tools*
The moose likes Other Open Source Projects and the fly likes use Apache POI to read Excel file problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Other Open Source Projects
Bookmark "use Apache POI to read Excel file problem" Watch "use Apache POI to read Excel file problem" New topic
Author

use Apache POI to read Excel file problem

reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
I am new to use Apache POI / HSSF. I'm trying to read an Excel file. Here is the code:


But when I run it, I got:

java.io.IOException: block[ 0 ] already removed
at org.apache.poi.poifs.storage.BlockListImpl.remove(BlockListImpl.java:97)
at org.apache.poi.poifs.storage.BlockAllocationTableReader.fetchBlocks(BlockAllocationTableReader.java:190)
at org.apache.poi.poifs.storage.BlockListImpl.fetchBlocks(BlockListImpl.java:130)
at org.apache.poi.poifs.storage.SmallBlockTableReader.getSmallDocumentBlocks(SmallBlockTableReader.java:61)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:176)
at MasterTable.main(MasterTable.java:29)


Dose someone know what's the problem with this code? Or is the excel input file has problem? Thanks.


SCJA, SCJP5.0, SCBCD, SCWCD
Rene Larsen
Ranch Hand

Joined: Oct 12, 2001
Posts: 1179

Is "blah.xls" an existing Excel file?? and is "sh1" an existing sheet??

Maybe you can have use of this POI Quick Guide


Regards, Rene Larsen
Dropbox Invite
reubin haz
Ranch Hand

Joined: May 12, 2005
Posts: 287
The file name and sheet name are correct. I have double checked it. The program failed in the 1st line, even before accessing the sheet...
Yves Zoundi
Ranch Hand

Joined: Aug 31, 2008
Posts: 47
Another think you might want to check is if the version of Apache POI supports file Excel file version.

A simple way to test that it's not Apache POI's fault would be to iterate through the sheets without sheets name or cell indexes(ie. using the iterators that POI provides for the sheets and rows).
You'll be able to ensure that the sheet name that you're requesting correspond to the ID that POI has in memory.


Author of VFSJFileChooser and XPontus XML Editor
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: use Apache POI to read Excel file problem