• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

use Apache POI to read Excel file problem

 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Rene Larsen
Ranch Hand
Posts: 1179
Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is "blah.xls" an existing Excel file?? and is "sh1" an existing sheet??

Maybe you can have use of this POI Quick Guide
 
reubin haz
Ranch Hand
Posts: 287
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 47
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic