Link to home
Start Free TrialLog in
Avatar of lincstech
lincstech

asked on

programming render and save reportviewer

Hello,

I'm looking to find a solution on how to programming render a report viewer document and save the document as a PDF. So far I've established this small line of code however, I'm sure there is more to it that I am missing.

ReportViewer1.LocalReport.Render

Open in new window

Avatar of devlab2012
devlab2012
Flag of India image

Render the report into a byte arrary and then save this array into a PDF file.


Here is a code snippet for this :


String reportFormat = "PDF";

FileStream stream = null;
String filePath = "";

String mimeType;
String encoding;
String fileNameExtension;
Microsoft.Reporting.WebForms.Warning[] warnings;
String[] streamIds;

//Render the report into a byte arrary, then save this byte arrary to a file
          byte[] reportBytes = ReportViewer1.ServerReport.Render(reportFormat, null, out mimeType, out encoding, out fileNameExtension, out streamIds, out warnings);
          filePath = Server.MapPath("ReportFolder") + "/" + "MyPDFReport" + "." + fileNameExtension;
          stream = new System.IO.FileStream(filePath, System.IO.FileMode.Create);
          stream.Write(reportBytes, 0, reportBytes.Length);
String reportFormat = "PDF";

FileStream stream = null;
String filePath = "";

String mimeType;
String encoding;
String fileNameExtension;
Microsoft.Reporting.WebForms.Warning[] warnings;
String[] streamIds;

//Render the report into a byte arrary, then save this byte arrary to a file
          byte[] reportBytes = ReportViewer1.ServerReport.Render(reportFormat, null, out mimeType, out encoding, out fileNameExtension, out streamIds, out warnings);
          filePath = Server.MapPath("ReportFolder") + "/" + "MyPDFReport" + "." + fileNameExtension;
          stream = new System.IO.FileStream(filePath, System.IO.FileMode.Create);
          stream.Write(reportBytes, 0, reportBytes.Length);

Open in new window

Avatar of lincstech
lincstech

ASKER

Is this a Visual Basic.net code or C Sharpe coding ? I'm looking for VB.net
ASKER CERTIFIED SOLUTION
Avatar of devlab2012
devlab2012
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial