How do you export a report to stream using C Sharp (C#) for Visual Studio .NET?
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
public partial class _Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
//prepare report
ReportDocument reportDocument = new ReportDocument();
reportDocument.Load(Server.MapPath("MyReport.rpt"));
//export report to stream
System.IO.Stream stream = reportDocument.ExportToStream (CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
reportDocument.Dispose();
//Send pdf to client
byte[] PDFByteArray = new Byte[stream.Length];
stream.Position = 0;
stream.Read(PDFByteArray, 0,Convert.ToInt32(stream.Length));
Context.Response.ClearContent();
Context.Response.ClearHeaders();
Context.Response.AddHeader("content-disposition", "filename=Report.pdf");
Context.Response.ContentType = "application/pdf";
Context.Response.AddHeader("content-length", PDFByteArray.Length.ToString());
Context.Response.BinaryWrite(PDFByteArray);
Context.Response.Flush();
Context.Response.End();
>
>
Export PDF stream visual studio .net , 2942555 , KBA , BI-DEV-NET , How To
SAP Crystal Reports, developer version for Microsoft Visual Studio ; SAP Crystal Reports, version for Visual Studio .NET 2008