October 7, 2010 at 4:42 pm
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.
October 8, 2010 at 2:52 am
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
Raunak J
October 8, 2010 at 11:33 am
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.
October 10, 2010 at 10:12 pm
try try until you succeed...:-):-):-)
Raunak J
October 10, 2010 at 10:31 pm
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
October 10, 2010 at 10:35 pm
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)
Raunak J
October 25, 2010 at 2:43 pm
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
October 27, 2010 at 10:56 am
This link gave me the answer. Thanks for your help!
http://stackoverflow.com/questions/915999/password-protecting-an-excel-file-in-c
October 27, 2010 at 10:44 pm
Thanks for replying back 🙂
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!!! 🙂
Raunak J
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply