CodeWare

ReportServer

Exporting a SQL Server Reporting Services Report Directly to PDF

by Bruno Rebelo on Feb.11, 2009, under C#, ReportServer

?View Code CSHARP
 
ReportViewer report = new ReportViewer();
report.ServerReport.ReportServerUrl = new Uri(@"http://localhost/reportserver");
report.ServerReport.ReportPath = "/ReportFolder/ReportName";
string mimeType, encoding, extension, deviceInfo;
string[] streamids;
Warning[] warnings;
string format = "PDF"; //Desired format  (PDF, Excel, or Image)
deviceInfo =
   "<DeviceInfo>" +
   "<SimplePageHeaders>True</SimplePageHeaders>" +
   "</DeviceInfo>";
byte[] bytes = report.ServerReport.Render(format, deviceInfo, out mimeType, out encoding, out extension, out streamids, out warnings);
System.IO.FileStream sw;
sw = new System.IO.FileStream(@"c:\output.pdf", System.IO.FileMode.OpenOrCreate);
for (int i = 0; i < bytes.Length; i++)
   sw.WriteByte(bytes[i]);
sw.Close();
Leave a Comment more...

How to call a report (reportserver) using C#

by Bruno Rebelo on Feb.11, 2009, under C#, ReportServer

After your report been deployed, you have to add a REPORTVIEWER to your form and then :

?View Code CSHARP
            reportURL.Text = "/REPORT1/report";
            reportURL.ProcessingMode = Microsoft.Reporting.WinForms.ProcessingMode.Remote;
            reportURL.ServerReport.ReportServerUrl = new Uri(@"http://localhost/reportserver");
            reportURL.ServerReport.ReportPath = reportURL.Text;
            reportURL.RefreshReport();

voilá… there its your report

Leave a Comment more...

Procurando algum código?

Utilize o formulário para procurar:

Não encontrou o que queria? Deixe um comentário num CODE ou contacte-nos para encontrar-mos solução!

Visit our friends!

A few highly recommended friends...