views:

232

answers:

2

Is anyone familiar with a library or tool that can determine which format an excel file is in? Or, failing that, documentation on the different formats that would allow me to write my own?

A: 

The Excel file format is called the Binary Interchange File Format (BIFF) there are different versions of Excel that use the same version of BIFF.

Open Office document on the Excel File Format.

Take a look at the Open Office API, this should help you.

Mark Robinson
A: 

Excel 97-2003 workbooks are known as Biff8. They are actually OLE Compound documents which are essentially a file system within a file. They store the main workbook in a stream named "Workbook" and they have other streams for VBA modules, OLE objects, document properties, etc...

Win32 includes APIs for reading OLE Compound Documents. They are far from trivial. Once you get the "Workbook" stream, the first Biff record identifies the file as being an Excel file.

You can find excellent documentation from Microsoft on the Biff8 file format on the Microsoft Office Binary File Formats page.

The new Excel 2007 Open XML (xlsx) format is actually a zip file with workbook parts and is documented at OpenXmlDeveloper.org.

I am not aware of a tool which will simply tell you the format of a workbook. You could take the easy, but not very reliable approach of just looking at the extension which will be right 99%+ of the time - if accuracy is not an issue.

There are many tools to read xls and xlsx workbooks, including SpreadsheetGear for .NET which reads both.

Disclaimer: I own SpreadsheetGear LLC

Joe Erickson