public static void RenderCrystalReport(DataSet ResultSet, String ReportLocation, String RenderType,HttpResponse Response) { MemoryStream oStream = new MemoryStream(); ReportDocument crystalReport = new ReportDocument(); crystalReport.Load(HttpContext.Current.Server.MapPath(ReportLocation)); crystalReport.SetDataSource(ResultSet); switch (RenderType) { case "PDF": oStream = crystalReport.ExportToStream(ExportFormatType.PortableDocFormat) as MemoryStream; Response.Clear(); Response.Buffer = true; Response.ContentType = "application/pdf"; break; case "DOC": oStream = crystalReport.ExportToStream(ExportFormatType.WordForWindows) as MemoryStream; Response.Clear(); Response.Buffer = true; Response.ContentType = "application/doc"; break; case "XLS": oStream = crystalReport.ExportToStream(ExportFormatType.Excel) as MemoryStream; Response.Clear(); Response.Buffer = true; Response.ContentType = "application/vnd.ms-excel"; break; } Response.BinaryWrite(oStream.ToArray()); Response.End(); }
Render Crystal Report in different file formats without CrystalReportViewer
C# Benedict Alphonse Monday, November 9, 2009 0 comments
Subscribe to:
Post Comments (RSS)
0 Responses to "Render Crystal Report in different file formats without CrystalReportViewer"
Post a Comment