简体   繁体   中英

How to export data to an Excel 2007 table using SSIS?

I have an excel file (xlsx) containing a table :

Excel表格

Once I launched my ssis task (successfully) to insert data in it, it is actually append after the table :

SSIS任务后的Excel表

My expected result:

预期

So I am looking for a way to insert into the table and expand it with the data. I hope someone could help me.

I would not use SSIS for this, you may have Excel2007 as linked server , putting data into Excel by regular TSQL, or process data by Excel VBA getting data directly from SQL Server. As a matter of practical sanity, I would not ever use SSIS for anything

Well, there is not much information how you do it but you should specify somehow that first row should not be used as header names container (HDR=NO), something like,

  • insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0',
    'Excel 8.0;Database=D:\\testing.xls; ; HDR=NO' ,
    'SELECT * FROM [Sheet1$]')

I finally found an answer. So I needed to generate excel reports with a lot of pivot charts linked to a main table.

But using a table was a bad idea. Instead, the pivot charts must be linked to a named range.

The last thing to know is that the error message "Invalid References" appears if the named range doesn't use the OFFSET function.

My named range formula is :

=OFFSET(Sheet!$A$1, 0, 0, COUNTA(Sheet!$A:$A), NUMBER_OF_COLUMNS)

Where Sheet is the name of the worksheet and NUMBER_OF_COLUMNS is the number of columns of the data.

That's it. I can now generate excel report without any line of code, only using SSIS 2005.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM