Problem: An Excel file (XLSX) dynamically created by a SQL Task cannot be opened via Excel. The task succeeds, but when you try to open the workbook in Excel you get the fillowing error message: Excel cannot open the file 'myfile.xlsx" because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.
Observations:
1. If the Excel file (xlsx) is created manually in Excel, then the SQL Task has no problem creating table (new worksheets) in the xlsx (so the "CREATE TABLE" statement works fine)
2. If I adjust the connection and task to work with Excel 97-2003 (xls) format then the approach works perfectly
3. The execution results show success of the SQL Task, but there are two warning messages. These same warnings appear when the SQL Task creates a new table (worksheet) successfully in a workbook (xlsx) which was created manually in Excel (and is not corrupt).
Messages as follows:
Warning: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
Warning: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done.
SSIS Details:
1. ConnectionString: "Data Source=" + @[User::ExcelFileFullPathName] + ";Provider=Microsoft.ACE.OLEDB.12.0;Extended Properties=\"Excel 12.0;HDR=YES\";"
2. SQLStatementSource (from SQL Task):
"CREATE TABLE `" + @[User::cfgExcelTransformTableName] + "` (
`Number` VarChar(15),
`Name` VarChar(252),
`Site/Organization` VarChar(255),
`Priority` VarChar(255),
`Description` LongText,
`Status` VarChar(255),
`Start Date` VarChar(255),
`End Date` VarChar(255),
`Category` VarChar(255),
`Project Contact` VarChar(255),
`Sponsor` VarChar(255),
`Funding Source` VarChar(255),
`Partner` LongText,
`Budget` Double,
`Allocated Funding by Source` VarChar(255),
`Allocated Funding` Double,
`Expended Funding` Double,
`Habitat Type` VarChar(255),
`Limiting Factors` VarChar(255),
`Primary Species Benefiting` VarChar(255),
`Secondary Species Benefiting` VarChar(255),
`Current Project Status` VarChar(255),
`Activity Type(s)` LongText
)
"
3. Run64BitRuntime = False
Hardware/Software Details:
1. Windows 7 Ultimate (64 bit)
2. Excel Version 14.0.4760.1000 (64 bit)
3. Visual Studio 2008
4. Office 2007 Data Connectivity Components:
http://www.microsoft.com/downloads/en/confirmation.aspx?FamilyID=7554F536-8C28-4598-9B72-EF94E038C891&displaylang=en