You can use this as a common method to create reports. Here a dynamic pdf will be generated with the time ticks
//using
using Microsoft.Reporting.WebForms;
public static void GenerateReport(string repName,ref ReportViewer rv)
{
string mimeType;
string encoding;
string fileNameExtension;
Warning[] warnings;
string[] streamids;
byte[] exportBytes = rv.LocalReport.Render("PDF", null, out mimeType, out encoding, out fileNameExtension, out streamids, out warnings);
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ContentType = mimeType;
HttpContext.Current.Response.AddHeader("content-disposition", "attachment; filename="+repName+ DateTime.Now.TimeOfDay.Ticks.ToString() + "." + fileNameExtension);
HttpContext.Current.Response.BinaryWrite(exportBytes);
HttpContext.Current.Response.Flush();
HttpContext.Current.Response.End();
}
No comments:
Post a Comment