Quantcast
Channel: Open XML Format SDK forum
Viewing all articles
Browse latest Browse all 1288

OpenXML and powershell Copy of Worksheet to Workbook

$
0
0

Hello Everyone,

I looked at a few threads and quite didn't find a simple answer.

I have a powershell script that pulls SSRS reports in EXCELOPENXML format. These reports are pulled in a loop with different paramters and then subsequently consolidated as mutiple worksheets in to a single spreadsheet. I always take the first sheet of the SSRS report excel.

I am able to do this using excel interop and now want to scale this and schedule it as task. Excel doesn't usually liek that nor does MS support it.

I do want the sheet to be copied as-is including values, formatting, charts (future). Is this something easy to do in openXML and if someone has already created functions for it, please share

Here is the code snippet in powershell , this is in a for-each loop

SSRSexcelExport$tempfileName$_.Report_server.trimend()$_.Report_location.trimend()$_.No_of_parm$parm1$parmvalue1$parm2$parmvalue2$parm3$parmvalue3

$wb2=$xl.workbooks.open($tempfileName,$null,$true

$sheetfromCopy     =$wb2.sheets.item(1) # source worksheet

$sheetfromCopy.Name=$_.tab_name.trimend() #this the name I want in the destination worksheet

$sheettoCopy       =$wb1.sheets.item(1) # Insert as the first sheet in the destination

$sheetfromCopy.copy($sheettocopy)

$wb2.close($false


Viewing all articles
Browse latest Browse all 1288

Trending Articles