Posts

Showing posts with the label Export

Emailing Exported File from SQL Server Reporting Services 2005

Image
I have created a sample class to email exported reports [PDF, Excel etc.] from SQL Reporting Services. To do that, I had to add a Report Viewer into the form and set Visible property to False. This web form actually grabs the parameter values from query string and process the report accordingly. You may call this form from another web page and pass the parameters like this:   =================================================== Email form calling function =================================================== private void emailReport() { try { string _period1 = Convert .ToString( Convert .ToDateTime(dtStartDate.Value.ToString()).ToString( "yyyyMM" )); string _period2 = Convert .ToString( Convert .ToDateTime(dtEndDate.Value.ToString()).ToString( "yyyyMM" )); string _division = Convert .ToString(ddDivisions.SelectedValue.ToString()); string _department = Convert .ToString(ddDepartment.SelectedValue.ToString()); string _employee = "" ; ...

Programmatically Export from SQL Reporting Services in C#

Here is the sample code for rendering SQL Reporting Services Report to desired file types (PDF, XLS etc.): private void generateReport( string _ReportName, string _period1, string _period2, string _division, string _department, string _employee) { try { string _ReportServer = System.Configuration. ConfigurationManager .ConnectionStrings[ "ReportServer" ].ToString(); string _ReportPath = System.Configuration. ConfigurationManager .ConnectionStrings[ "ReportPath" ].ToString(); ReportViewer1.ProcessingMode = ProcessingMode .Remote; Uri ReportURI = new Uri (_ReportServer); this .ReportViewer1.ServerReport.ReportServerUrl = ReportURI; this .ReportViewer1.ServerReport.ReportPath = _ReportPath + _ReportName; int repParams = 2; switch (_ReportName) { case "/ExpenseReportByDivision" : repParams = 2; break ; case "/ExpenseReportByDepartment" : repParams = 3; break ; case "/ExpenseReportByEmployee" : ...