views:

74

answers:

2

Hello !

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

Excel Table

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

Excel Table after the SSIS task

My expected result:

Expected

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

Thank you !

+1  A: 

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$]')
vgv8
I really need to use SSIS. I have found a way to insert data into an Excel table with C#, using the OpenXML SDK. But I am still looking for a way to do it directly into SSIS. I would be surprised it is not possible. Unfortunately, [WorksheetName].[TableName] doesn't work :( I'll post my finale solution, unless someone provide me a solution.
Julio Guerra
I resign myself to code with ExtremeML!
Julio Guerra
Yeaah, I did not work with Excel for quite a time but I remember that in 2007 it is possiblу to work directly with XML schema of underlying sheets data (what is not available in 2003)
vgv8
A: 

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.

Julio Guerra