how to import Excel's several sheets to DB?

  • hi,

    I made a package which I import Excel file data (just one sheet) to DB.

    and It works fine.

    But My Excel file has more than 3 sheets. Each format is the same.

    I want package to read all 3 sheets.

    Could someone please tell me how to do this??

    thank you.:)

  • Take a look at the foreach container. using a variable which you set to each sheet's name or index, you can loop through the sheets and perform the transformation. hope this helps.

    Karen

  • Hi,Karen.

    Thank you very much for replying me.

    I found this site : http://msdn.microsoft.com/en-us/library/ms345182.aspx

    I tried Foreach Loop Container to loop one data flow which is to read, to transform, and to insert data into DB.

    But this was designed only one sheet "Sheet1" s data to be inserted.

    after I created a data flow task in a foreach loop container, I executed it.

    it seems sheet is looped. I can see the sheet name changes after one loop is done.

    But, it is inserting the same sheet's data for 3 times.

    do you have any idea where else I need to change??

    thank you,

    tomoko

  • In keeping with SSIS' apparent campaign to stamp out encapsulation, the sheet name variable is hidden in the Excel Source\Advanced Editor\Component Properties\ OpenRowsetVariable, which in my case I set to User::TabName. (I did not have advanced knowledge of the tabs/range names, which I had to find in a Script task which I copied from a MS MSDN page and set the TabName variable.)

    UPDATE:

    I probably led you astray with the ablve answer, which I left after inspecting a task in which I also had to specify an Excel sheet name. The more direct way is in the Excel Source Editor (your input data flow task) -- not the Advanced Editor. There, set your "Data access mode:" to "Table name or view name variable", and set the "Variable name:" field to the name of your variable containing the range or sheet name, in my case "User::TabName". Keep in mind that, unlike range names, the Tab Names are suffixed with a "$", e.g. "My Sheet1$".

    How in the world does anyone know whether to look in an Editor", an "Advanced Editor, the parameters of a task, or its Expressions to find/use a needed setting? It is madness!

  • Hi,

    I usually do this almost everyday at my job place. I have to get the data from different excel files in one package. I use a very simple method. In the control flow, I drag and drop one dataflow and then I have 3 excel sources in a single data flow task. That means 3 excel connection managers also. And then, I use the data conversion transformation and finally the SQL Server destination. It works fine. I get the data from all three different excel files by executing a single package.

    One important thing here. Make sure that in your destination, in the properties window, the tablock option is off. Tablock is on by default, so you need to turn it off or mention it as false in order to get the data from all three sheets.

    Hope this works for you too.

    Thanks.

    notes4we

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply