Click here to monitor SSC
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
Grasshopper
Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)

Group: General Forum Members
Points: 21 Visits: 40
SQL Server Version = 2005

Not sure about pushing to a sharepoint doc. Can you give me some more details? You want to push to a specific type of doc? Or is it that you want to push TO the sharepoint?
Philippe Cand
Philippe Cand
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: 294
That would be creating on the fly a new Excel in SharePoint doc library with a path similar to this
http://smportal.onsemi.com/C10/Reporting%20Projects/Development%20Process%20and%20Templates/MyWorkbook.xls

BI Guy
mdeschen1
mdeschen1
Grasshopper
Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)

Group: General Forum Members
Points: 21 Visits: 40
to create the file on the sharepoint site I would try to treat it just as a file address. That means in your variable (see the article for specifics) I would specify the path:
SHAREPOINT_FILESYSTEM_ADDRESS\20Templates/"+(DT_STR.25.1254)@[User::YOUR_VARIABLE]+"xls"

Ok, sharepoint has a real, physical filesystem. Push the file to there. Make the directory/folder always visible on sharepoint OR overwrite with the same file name each time and just have the file visible (this was done at one of the sites I was at last year).

Let me know how it goes.
Aseda
Aseda
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 247
--SQL Server and call xp_cmdshell to modify/re-massage/rename/move/.. your xls file.
how do you do this? i am using xp_cmshell to output data from a sql table to different tabs in excel. I only get the last set of data in the cursor in the first tab
mdeschen1
mdeschen1
Grasshopper
Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)Grasshopper (21 reputation)

Group: General Forum Members
Points: 21 Visits: 40
Forum Newbie: Is the last question aimed at this article? The article does not use:xp_cmshell

But I can say that if you populate the tab cursor from the SQL Execute Task before the Foreach Loop you will definitely get a different tab for each value. Now, to populate each tab with the correct values you need a variable set up for the data pull (cols etc etc) that is also part of the solution.

IF you want to use xp_cmshell I am afraid I cannot help you. :-)
imaddaou
imaddaou
Grasshopper
Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)Grasshopper (10 reputation)

Group: General Forum Members
Points: 10 Visits: 24
SQL Server 2005
Philippe Cand
Philippe Cand
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: 294
Great, It works perfectly.
I just have to put together the mechanism with the variables.
so instead of an URL not supported by JET, use an UNC
In my example I simply have to use variables or configurations to build the path.
instead of the original
http://smportal.onsemi.com/C10/Reporting%20Projects/Development%20Process%20and%20Templates/CalendarWeeks.xls
I use this
\\smportal.onsemi.com\C10\Reporting Projects\Development Process and Templates\CalendarWeeks.xls

BI Guy
rdobrich
rdobrich
SSC Rookie
SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)

Group: General Forum Members
Points: 26 Visits: 43
Hi,
I finaly did it and it works realy great.

There is one thing I had to change.
I had a problem (or I didn't get it right) with Execute task (to create new TAB within same exec file).
When I changed variable ExcelTab to something like this

"CREATE TABLE `" + @[User::region] + "` (
`my_field` VARCHAR(50)
)"

works perfectly

Thanks for the article. I realy find a lot of interesting stuff in it.

radovan



imadaou
imadaou
Forum Newbie
Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)Forum Newbie (1 reputation)

Group: General Forum Members
Points: 1 Visits: 9
Can you please list all variables you used?

I was able as well to make the package work by using "CREATE TABLE `" + @[User::region] + "` (
`my_field` VARCHAR(50)
)" before adding the Dataflow task. When I added the dataflow task and assigned the variable to the Excel Destination it didn't alow me. what did you use for the variable ‘Subgroups’ ?

Thanks in advance
rdobrich
rdobrich
SSC Rookie
SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)SSC Rookie (26 reputation)

Group: General Forum Members
Points: 26 Visits: 43
Hi,
I little change sample, so I use this variables:

1)
FilePath='c:\temp\sample.xls'
(but, I can dynamicly create file name through expression properties, like
"c:\\temp\\test_" + substring((DT_STR, 50,1250) GETDATE(),1,10)+".xls"
if I need file name
c:\temp\test_2008-01-10.xls

EvaluateAsExpression property needs to be 'True'

2)
In Excel connection manager in Expression Property I set 'excelFilePath' to @[User::FilePath]

3)
ExcelTab Variable is set throuh Expression to
(EvaluateAsExpression property needs to be 'True')

"CREATE TABLE `" + @[User::region] + "` (
`my_field` VARCHAR(50)
)"

4) In Execute SQL Task, I Set
Connection Type to 'Excel'
Connection to existing Excel connection manager (created in step 2)
SQl source type to 'Variable'
SourceVariable to 'User::ExcelTab' (created in step 3)

Execute workws perfectly if excel file with @[User::region] doesn't exists.
It will fail if it exists.

radovan



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