Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12345»»»

How to Dynamically and Iteratively Populate An Excel Workbook from SQL Server Expand / Collapse
Author
Message
Posted Tuesday, January 8, 2008 10:44 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, November 30, 2009 8:07 PM
Points: 15, Visits: 40
Comments posted to this topic are about the item How to Dynamically and Iteratively Populate An Excel Workbook from SQL Server
Post #440424
Posted Wednesday, January 9, 2008 7:23 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, January 14, 2011 2:11 AM
Points: 24, Visits: 43
Please, can you explane how do you create ExcelFileName and TAB
variable.
I can't see it cleary from the picture.

radovan



Post #440635
Posted Wednesday, January 9, 2008 7:33 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Friday, July 25, 2014 7:38 AM
Points: 1,221, Visits: 1,286
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/
Post #440650
Posted Wednesday, January 9, 2008 8:03 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, June 18, 2010 12:14 PM
Points: 8, 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_..
Post #440680
Posted Wednesday, January 9, 2008 8:48 AM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Yesterday @ 3:48 PM
Points: 66, Visits: 359
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



Post #440726
Posted Wednesday, January 9, 2008 10:13 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, January 31, 2008 9:20 AM
Points: 10, 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
Post #440787
Posted Wednesday, January 9, 2008 10:20 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Yesterday @ 4:16 PM
Points: 40, Visits: 530
What version of SQL Server?


Post #440794
Posted Wednesday, January 9, 2008 10:42 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, November 30, 2009 8:07 PM
Points: 15, 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
Post #440811
Posted Wednesday, January 9, 2008 11:07 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Monday, November 30, 2009 8:07 PM
Points: 15, 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....
Post #440823
Posted Wednesday, January 9, 2008 11:26 AM


SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Wednesday, July 23, 2014 12:10 PM
Points: 49, Visits: 279
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
Post #440827
« Prev Topic | Next Topic »

Add to briefcase 12345»»»

Permissions Expand / Collapse