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


Export SSRS Report to Password Protected Excel File


Export SSRS Report to Password Protected Excel File

Author
Message
SlowJamuels
SlowJamuels
SSC Journeyman
SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)

Group: General Forum Members
Points: 85 Visits: 102
Hi,

I developed a report that is currently running on SSRS 2008 R2. Every day I have to run the report, export it to Excel, password protect the .XLS file, then email the file out to a few people.

I was using a free trial of SQL-RD to handle this task and it went well. However, the free trial is up now and the license for the software is $10,000!

I'm fairly certain this can be done in SSIS, I'm just not exactly sure how. Does anyone know?

Again, the steps are:

1. Export SSRS report to Excel
2. Password protect the .XLS file
3. Email the file

Thanks in advance.
Raunak Jhawar
Raunak Jhawar
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3545 Visits: 1944
This is not as easy as it looks.

SSIS Approach:

As usual export the report as excel file --> Using SSIS Script Task(Excel COM Components) encrypt the file --> Email the file(using the Send Email Task)

.NET API Approach:

Capture the Excel file using the WQL Query of FileWatcher-->Encrypt the file-->Email the File

Regards/Raunak
Now a member of Linkedin

Please visit the all new Performance Point Forum
Please visit the all new Data Mining and Business Analytics Forum
SlowJamuels
SlowJamuels
SSC Journeyman
SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)

Group: General Forum Members
Points: 85 Visits: 102
Using SSIS Script Task(Excel COM Components) encrypt the file


How do I do this part?

Do you have any examples or reading that you can point me to?

I did a google and bing search but nothing helpful came up.

Thanks a lot for your help.
Raunak Jhawar
Raunak Jhawar
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3545 Visits: 1944
try try until you succeed...:-):-):-)

Regards/Raunak
Now a member of Linkedin

Please visit the all new Performance Point Forum
Please visit the all new Data Mining and Business Analytics Forum
WayneS
WayneS
SSC-Insane
SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)

Group: General Forum Members
Points: 20726 Visits: 10652
Well, SSIS does use the Jet driver, via OpenRowSet, to work with Excel files. So, this link will probably help you out. You would just need to add it to the extended properties of the Excel Configuration in the properties window.

Wayne
Microsoft Certified Master: SQL Server 2008
Author - SQL Server T-SQL Recipes
If you can't explain to another person how the code that you're copying from the internet works, then DON'T USE IT on a production system! After all, you will be the one supporting it!
Links: For better assistance in answering your questions, How to ask a question, Performance Problems, Common date/time routines,
CROSS-TABS and PIVOT tables Part 1 & Part 2, Using APPLY Part 1 & Part 2, Splitting Delimited Strings

Raunak Jhawar
Raunak Jhawar
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3545 Visits: 1944
WayneS (10/10/2010)
Well, SSIS does use the Jet driver, via OpenRowSet, to work with Excel files. So, this link will probably help you out. You would just need to add it to the extended properties of the Excel Configuration in the properties window.


Wayne, what is a better approach of the two

1. SSIS Excel Com Components
OR
2. Implementing a .NET API (I vote for .NET API)

Regards/Raunak
Now a member of Linkedin

Please visit the all new Performance Point Forum
Please visit the all new Data Mining and Business Analytics Forum
SlowJamuels
SlowJamuels
SSC Journeyman
SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)

Group: General Forum Members
Points: 85 Visits: 102
I've been able to export the report to an Excel file, but I'm having trouble figuring out how to Encrypt the new file. Below is the code in my export script task. Is it possible to add the encryption command to this script task, or will I have to create a new task? If so, what type of task do I need to create? Thanks again!



Protected Sub SaveFile(ByVal url As String, ByVal localpath As String)
Dim loRequest As System.Net.HttpWebRequest
Dim loResponse As System.Net.HttpWebResponse
Dim loResponseStream As System.IO.Stream
Dim loFileStream As New System.IO.FileStream(localpath, System.IO.FileMode.Create, System.IO.FileAccess.Write)
Dim laBytes(256) As Byte
Dim liCount As Integer = 1

'Try
loRequest = CType(System.Net.WebRequest.Create(url), System.Net.HttpWebRequest)
loRequest.Credentials = New System.Net.NetworkCredential(Dts.Variables("varSSRS_LOGIN").Value.ToString(), Dts.Variables("varSSRS_PASSWORD").Value.ToString(), Dts.Variables("varSSRS_DOMAIN").Value.ToString())
loRequest.Timeout = 600000 'timeout 15 minutes
loRequest.Method = "GET"
loResponse = CType(loRequest.GetResponse, System.Net.HttpWebResponse)
loResponseStream = loResponse.GetResponseStream
Do While liCount > 0
liCount = loResponseStream.Read(laBytes, 0, 256)
loFileStream.Write(laBytes, 0, liCount)
Loop
loFileStream.Flush()
loFileStream.Close()
'Catch ex As Exception

'End Try

End Sub


Public Sub Main()
Dim url As String
Dim outpath As String

outpath = Dts.Variables("varDestinationPath").Value.ToString + Dts.Variables("varReportName").Value.ToString() + " - " + Format(Now, "yyyyMMdd") + ".xls"

url = Dts.Variables("varSSRS_URL").Value.ToString() + "?%2fReports%2fCaseSmart%2f" + Dts.Variables("varReportName").Value.ToString() + "&rs:Command=Render&rs:Format=EXCEL"

SaveFile(url, outpath)

Dts.TaskResult = ScriptResults.Success

End Sub




Raunak Jhawar
Raunak Jhawar
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3545 Visits: 1944
Please follow here

Regards/Raunak
Now a member of Linkedin

Please visit the all new Performance Point Forum
Please visit the all new Data Mining and Business Analytics Forum
SlowJamuels
SlowJamuels
SSC Journeyman
SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)SSC Journeyman (85 reputation)

Group: General Forum Members
Points: 85 Visits: 102
This link gave me the answer. Thanks for your help!

http://stackoverflow.com/questions/915999/password-protecting-an-excel-file-in-c
Raunak Jhawar
Raunak Jhawar
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3545 Visits: 1944
Thanks for replying back Smile

Just incase if time permits,

Try the following which I found simply awesome!! But try only if time permits and you are ready to bang your head :-)

Ok,

I was about to give you the code but try on your self...

Try implementing a FileSystemWatcher or WQL (please google, incase) on a specific directory to detect whether the file/excel report has arrived. Then trigger the API for file encryption and File Email

This is intense automation we are talking!!! :-)

Regards/Raunak
Now a member of Linkedin

Please visit the all new Performance Point Forum
Please visit the all new Data Mining and Business Analytics Forum
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