SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to Dynamically and Iteratively Populate An Excel Workbook from SQL Server


How to Dynamically and Iteratively Populate An Excel Workbook from SQL Server

Author
Message
mdeschen1
mdeschen1
SSC-Enthusiastic
SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)

Group: General Forum Members
Points: 139 Visits: 40
Comments posted to this topic are about the item How to Dynamically and Iteratively Populate An Excel Workbook from SQL Server
rdobrich
rdobrich
SSC-Enthusiastic
SSC-Enthusiastic (124 reputation)SSC-Enthusiastic (124 reputation)SSC-Enthusiastic (124 reputation)SSC-Enthusiastic (124 reputation)SSC-Enthusiastic (124 reputation)SSC-Enthusiastic (124 reputation)SSC-Enthusiastic (124 reputation)SSC-Enthusiastic (124 reputation)

Group: General Forum Members
Points: 124 Visits: 43
Please, can you explane how do you create ExcelFileName and TAB
variable.
I can't see it cleary from the picture.

radovan



Mike01
Mike01
Hall of Fame
Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)Hall of Fame (3.6K reputation)

Group: General Forum Members
Points: 3577 Visits: 1533
Can you provide the SSIS package. It's difficult to see the screen shots and to follow

For better, quicker answers, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Andrei Moskalev
Andrei Moskalev
SSC Rookie
SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)SSC Rookie (42 reputation)

Group: General Forum Members
Points: 42 Visits: 22
you can simple use output from your SQL Server and call xp_cmdshell to modify/re-massage/rename/move/.. your xls file.

I did it even within Unix (Excel will open your tab delimited output when you add xls extension to your file).

I did not like DTS, but SSIS can do the same, but I still prefer to use combination of batch file with ISQL and xp_..
gregsoc
gregsoc
SSC-Enthusiastic
SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)SSC-Enthusiastic (100 reputation)

Group: General Forum Members
Points: 100 Visits: 435
Can you post more detail on how you get the filename created and the tab names.
Can't really make anything out in the pictures



imaddaou
imaddaou
Valued Member
Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)

Group: General Forum Members
Points: 64 Visits: 24
Check this link. It has a more detailed sample.
http://rafael-salas.blogspot.com/2006/12/import-header-line-tables-into-dynamic_22.html
kathy o
kathy o
SSC-Enthusiastic
SSC-Enthusiastic (165 reputation)SSC-Enthusiastic (165 reputation)SSC-Enthusiastic (165 reputation)SSC-Enthusiastic (165 reputation)SSC-Enthusiastic (165 reputation)SSC-Enthusiastic (165 reputation)SSC-Enthusiastic (165 reputation)SSC-Enthusiastic (165 reputation)

Group: General Forum Members
Points: 165 Visits: 1072
What version of SQL Server?



mdeschen1
mdeschen1
SSC-Enthusiastic
SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)

Group: General Forum Members
Points: 139 Visits: 40
Hopefully here are some answers to the questions:

1. The filename actually is a variable. The variable was populated in the first Execute SQL task BEFORE the Foreach Loop. (Like a cursor). You dump values from a table into a variable.

Set the Excel Connection (notice that usually you specific connection 1, connection 2 etc but here NO specified number) to use a New Property expression. In the New Property expression and add the variable defined for the Excelsheet name. This variable references back to the cursor (called in this case 'Region' from the Execute SQL task).

As to the tabs...it is the same thing. A cursor is populated in the Execute SQL task called 'subregion'. This populated cursor is then used in a variable statement in the Foreach loop allowing the tabs to be created. Use the 'User:ListofSubgroups' value in the Variable name field within the Excel Destination Editor to create the tabs on the fly.

Now...as a 'heads up' To be able to create the Excel Destination the first time when developing the solution an actual Excel workbook with at least one tab must exist.

2. As with any solution there are definitely more ways than this one to 'skin a cat' and do this operation. This solution does not discuss how to push to 2007 Excel (we have just figured that one out). AND there is actually a way to totally code creation of an excel spreadsheet and tabs and population of same. It is not mine so I will not post here. This solution is for those that use SSIS packages preferentially.

The original motivator was to be able to do this WITHOUT having a template sitting on some filesystem. To that end we are one step closer to keeping everything in a SSIS solution.

Hoping the above helps....please keep the questions coming
mdeschen1
mdeschen1
SSC-Enthusiastic
SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)SSC-Enthusiastic (139 reputation)

Group: General Forum Members
Points: 139 Visits: 40
Radovan:

Were you able to pull down an actual version of the article? If so, you should be able to expand the screen prints. As well, I have posted more explanation here....
Philippe Cand
Philippe Cand
SSC-Addicted
SSC-Addicted (422 reputation)SSC-Addicted (422 reputation)SSC-Addicted (422 reputation)SSC-Addicted (422 reputation)SSC-Addicted (422 reputation)SSC-Addicted (422 reputation)SSC-Addicted (422 reputation)SSC-Addicted (422 reputation)

Group: General Forum Members
Points: 422 Visits: 294
Hello,
I like this article. Do you think that I could target a SharePoint portal document library?
Also, I would like the possibility to create a VBA module in addition to the excel tab.
Thanks
Philippe

BI Guy
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search