Feb
13
2009

Exporting data from SSIS to Excel 2007: Gotchas

The default Microsoft Excel 2007 file fomat, with the file extension .xslx, is in fact an XML file, or rather a Zip file that contains multiple XML files. However you can also save an Excel file in binary format, with the file extension .xlsb. For more information on Excel file formats, see File formats that are supported in Excel.

Our SQL Server Books Online topic, How to: Connect to an Excel Workbook, contains incomplete and potentially misleading information when it tells you to set Extended Properties = "Excel 12.0" on the OLE DB Connection Manager to work with an Excel 2007 file.

  • Importing. The driver doesn't care which of the 2 values (listed below) you use for Extended Properties when you are importing from Excel 2007. The driver infers the proper Excel file format from the existing input file. (However, you can't omit the Extended Properties value entirely, since by default the Jet Provider expects an Access file.)
  • Exporting. When you are exporting to Excel 2007, however, Extended Properties = "Excel 12.0" creates an Excel binary file, which is probably not what you expect. And, assuming that you gave your output file the usual .xslx file extension, the Excel application later complains that the file format is incorrect (because it's really .xlsb) and refuses to open the file.

The correct pairing of options that's critical for exporting to Excel 2007 is:

  • Default file extension of .xslx (Excel XML format), and Extended Properties = "Excel 12.0 Xml"
  • Non-default file extension of .xslb (Excel binary format), and Extended Properties = "Excel 12.0"

I only learned about these details today, and I don't believe that these options are documented anywhere. We will be updating the BOL topic as soon as possible.

-Doug

Comments (1) -

K

Thank you so much for the information and the big G for placing you #4 when searching for "ssis excel 12.0" (no quotes).  This is EXACTLY what I was looking for.  I'm so happy that I ran into this issue today and not a month ago Smile


Pingbacks and trackbacks (4)+