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

Export SSRS Report to Password Protected Excel File Expand / Collapse
Author
Message
Posted Thursday, October 7, 2010 4:42 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, May 13, 2014 1:09 PM
Points: 13, 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.
Post #1000961
Posted Friday, October 8, 2010 2:52 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, December 15, 2014 3:09 AM
Points: 1,046, Visits: 1,846
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
Post #1001081
Posted Friday, October 8, 2010 11:33 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, May 13, 2014 1:09 PM
Points: 13, 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.
Post #1001473
Posted Sunday, October 10, 2010 10:12 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, December 15, 2014 3:09 AM
Points: 1,046, Visits: 1,846
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
Post #1001899
Posted Sunday, October 10, 2010 10:31 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 12:27 PM
Points: 5,370, Visits: 9,008
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
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
Post #1001908
Posted Sunday, October 10, 2010 10:35 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, December 15, 2014 3:09 AM
Points: 1,046, Visits: 1,846
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
Post #1001911
Posted Monday, October 25, 2010 2:43 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, May 13, 2014 1:09 PM
Points: 13, 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



Post #1010401
Posted Monday, October 25, 2010 11:16 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, December 15, 2014 3:09 AM
Points: 1,046, Visits: 1,846
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
Post #1010532
Posted Wednesday, October 27, 2010 10:56 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, May 13, 2014 1:09 PM
Points: 13, Visits: 102
This link gave me the answer. Thanks for your help!

http://stackoverflow.com/questions/915999/password-protecting-an-excel-file-in-c
Post #1011739
Posted Wednesday, October 27, 2010 10:44 PM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Monday, December 15, 2014 3:09 AM
Points: 1,046, Visits: 1,846
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!!!


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
Post #1012059
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse