I have a xls file which i can open in excel, but when i try to open it with Apache POI, i get this exception :
java.io.IOException: block[ 3 ] already removed - does your POIFS have circular or duplicate block references?
at org.apache.poi.poifs.storage.BlockListImpl.remove(BlockListImpl.java:89)
at org.apache.poi.poifs.storage.RawDataBlockList.remove(RawDataBlockList.java:34)
at org.apache.poi.poifs.storage.BlockAllocationTableReader.fetchBlocks(BlockAllocationTableReader.java:221)
at org.apache.poi.poifs.storage.BlockListImpl.fetchBlocks(BlockListImpl.java:123)
at org.apache.poi.poifs.storage.RawDataBlockList.fetchBlocks(RawDataBlockList.java:34)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.processProperties(POIFSFileSystem.java:528)
at org.apache.poi.poifs.filesystem.POIFSFileSystem.<init>(POIFSFileSystem.java:163)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:327)
at org.apache.poi.hssf.usermodel.HSSFWorkbook.<init>(HSSFWorkbook.java:308)
at controlers.ExcelProject2.setBook(ExcelProject2.java:327)
at controlers.ExcelProject2.<init>(ExcelProject2.java:149)
at controlers.ExcelProject2Tests.main(ExcelProject2Tests.java:41)
The problem appears at this part of my code :
FileInputStream fs = new FileInputStream(pathFiles);
Workbook book = new HSSFWorkbook(fs);
If I open the file in excel, "Save as" and then open the new file with Java, it works. Even if I open the file and save, without changing anything, it works. I don't know why but the new file is bigger than the old one.
I have tried to use differents solution that i found on google, like using BOMInputStream or NPOI File but it didn't work. I'm currently using poi-3.8-20120326.
I can not share the file because it contains private information but there nothing else than number and String.
I remain at your disposal for more information.
Regards.
EDIT : I don't know if that makes a difference, but i have forgot to say that the file is in Compatibility mode