Can't read a BIFF8 file which Excel does read

Oct 1, 2009 at 7:25 PM

First of all, I am incredibly impressed at how well your library works.

Unfortunately, my attempts to use your library for reading binary Excel spreadsheets into a SQL Server database are coming to naught because the files I'm throwing at it are readable by Excel but not by your library. As near as I can tell, the breakage point is in the ReadWorksheet function, where your library can't seem to find the spreadsheet index:

 

private bool ReadWorksheet(XlsWorksheet sheet)
{
m_stream.Seek((int)sheet.DataOffset, SeekOrigin.Begin);
XlsBiffBOF bof = m_stream.Read() as XlsBiffBOF;
if (bof == null || bof.Type != BIFFTYPE.Worksheet)
return false;
XlsBiffIndex idx = m_stream.Read() as XlsBiffIndex;
bool isV8 = (m_version >= 0x600);

 

Interestingly, Excel 2003 makes noticeable changes to these problem files just by opening them and then saving. Once the file has been saved in Excel, it becomes readable by your library. Needless to say, using this work-around defeats my goal in using your library: avoiding having to invoke Excel to read these files, so that the process can be run on a server without installing MS Office on a server.

At this point, I'm totally stumped as to how Excel is deriving the worksheet index, much less where.

Have you encountered this behavior before?