Bug 50239 - OldExcelFormatException on BIFF8 file
Summary: OldExcelFormatException on BIFF8 file
Status: RESOLVED INVALID
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: 3.7-FINAL
Hardware: PC Windows Vista
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-09 06:41 UTC by Volker Jordan
Modified: 2011-01-20 11:20 UTC (History)
0 users



Attachments
Generated file that's mistaken for biff5 (11.00 KB, application/octet-stream)
2011-01-19 11:53 UTC, Bancika
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Volker Jordan 2010-11-09 06:41:17 UTC
Hi,

I got an excel file which I want to open:

FileInputStream inxls = new FileInputStream("file.xls");
HSSFWorkbook wb = new HSSFWorkbook(inxls);

This throws an exception

Warning, incorrectly terminated empty data blocks in POIFS block listing (should end at -2, ended at 0)
Warning, incorrectly terminated empty data blocks in POIFS block listing (should end at -2, ended at 0)
org.apache.poi.hssf.OldExcelFormatException: The supplied spreadsheet seems to be Excel 5.0/7.0 (BIFF5) format. POI only supports BIFF8 format (from Excel versions 97/2000/XP/2003)

When I take the XLVersionFromFile program from MS http://support.microsoft.com/kb/178605 I get:

The Excel Version is 8

I checked with 3.7 and 3.6.

What is wrong ?

Regards
Volker Jordan
Comment 1 Nick Burch 2010-11-09 07:02:55 UTC
Short term, try loading the file in excel and doing save-as - that'll hopefully fix the file up so whatever's confusing about it goes away

Longer term, could you please upload the file to this bugzilla entry so we can take a look and see what's unusual about it?
Comment 2 Volker Jordan 2010-11-09 07:16:49 UTC
Hi Nick,

I already opened and saved the file in excel and the error goes away.

As I work on an automated process without any manual intervention this is not an option for a long term fix.

I cannot upload the file because it contains sensible data. Would it help to provide you with some file headers in hex ?

Regards
Volker
Comment 3 Nick Burch 2010-11-09 07:26:19 UTC
Hmm, without the file it may be tough

Could you please send the output of running org.apache.poi.poifs.dev.POIFSLister against the file?

Also, where did the file come from? Was it produced by Excel (if so which version), or has it come from some third party system (eg a scientific instrument, a report package etc)
Comment 4 Volker Jordan 2010-11-09 08:08:38 UTC
(In reply to comment #3)
> Could you please send the output of running
> org.apache.poi.poifs.dev.POIFSLister against the file?

Hi Nick,

I ran the original and the resaved excel file against POIFSLister:

old file:
Root Entry -
Warning, incorrectly terminated empty data blocks in POIFS block listing (should end at -2, ended at 0)
  Book [7914 / 0x1eea]

new file:
Root Entry -
  CompObj <(0x01)CompObj> [114 / 0x72]
Warning, incorrectly terminated empty data blocks in POIFS block listing (should end at -2, ended at 0)
  DocumentSummaryInformation <(0x05)DocumentSummaryInformation> [224 / 0xe0]
  SummaryInformation <(0x05)SummaryInformation> [200 / 0xc8]
  Workbook [18365 / 0x47bd]

Concerning the producer of the excel file, I will come back to you later.

Regards
Volker
Comment 5 Bancika 2011-01-19 11:53:38 UTC
Created attachment 26518 [details]
Generated file that's mistaken for biff5

Here's file I generated with POI 3.6. I cannot read it with the same version of poi (says it's BIFF5 format, although it's not).
Cheers
Comment 6 Nick Burch 2011-01-20 10:16:11 UTC
(In reply to comment #5)
> Here's file I generated with POI 3.6. I cannot read it with the same version of
> poi (says it's BIFF5 format, although it's not).

The uploaded file doesn't have a "Workbook" entry, instead it only has a "Book" entry

What's more, I'm fairly sure that the file isn't an Excel 97+ file. When I rename the POIFS directory entry from Book to Workbook, HSSF complains because many of the records don't have enough data. This all makes me think that the file really is an older one as POI claims.
Comment 7 Bancika 2011-01-20 10:47:49 UTC
This is not a file I created with excel but using poi to export the data from my app. Can POI create a biff5 file at all? What am I doing wrong to make it go out as a biff5?

Here's a piece of the code I'm using

HSSFWorkbook wb = new HSSFWorkbook();
fileOut = new FileOutputStream(tempFile);
HSSFSheet sheet = wb.createSheet("Sheet1");
...
write data, formats and palettes to the sheet
...
wb.write(fileOut);
fileOut.close();

Thanks,
Bane
Comment 8 Nick Burch 2011-01-20 10:58:28 UTC
(In reply to comment #7)
> This is not a file I created with excel but using poi to export the data from
> my app. Can POI create a biff5 file at all? What am I doing wrong to make it go
> out as a biff5?

POI can't generate a biff5 file. I've no idea what you're doing, as I'm fairly sure that POI won't generate a file like the one you uploaded...

Nick
Comment 9 David Fisher 2011-01-20 11:16:52 UTC
When I open up the attached file in Mac Excel 2011, the file is reported as an "Excel 5.0 / 95 Workbook".

Perhaps the OP copied the file out of an app using POIFS?

Regards,
Dave
Comment 10 Bancika 2011-01-20 11:20:49 UTC
(In reply to comment #9)
> When I open up the attached file in Mac Excel 2011, the file is reported as an
> "Excel 5.0 / 95 Workbook".
> 
> Perhaps the OP copied the file out of an app using POIFS?
> 
> Regards,
> Dave

I used POI to generate that file, without even having the excel running. The
problem is in writing, not necessarily reading. I'll try extract the smallest
piece code that produces biff5 and attach it.