protected void Page_Load(object sender, EventArgs e) { int ProjId = Convert.ToInt32(Session["ProjId"]); RTSummaryMaterialWiseReport reports = new RTSummaryMaterialWiseReport(); reports.ReportParameters[0].Value = 1; reports.ReportParameters[1].Value = ProjId; ReportViewer1.ReportSource = reports; }
public void GetRTSummaryMaterialWisePDF(int ProjId, int CatId) { Random random = new Random(); int fileId = random.Next(1000, 9999); string fileName = $"spool_id_area_wise_{ fileId}.pdf"; string filePath = $@"C:\Temp\{fileName}"; RTSummaryMaterialWiseReport report = new RTSummaryMaterialWiseReport(); Telerik.Reporting.Processing.ReportProcessor reportProcessor = new Telerik.Reporting.Processing.ReportProcessor(); report.ReportParameters["ProjId"].Value = ProjId; report.ReportParameters["CatId"].Value = CatId; Telerik.Reporting.Processing.RenderingResult renderingResult = reportProcessor.RenderReport("PDF", report, null); FileStream fs = new FileStream(filePath, FileMode.Create); fs.Write(renderingResult.DocumentBytes, 0, renderingResult.DocumentBytes.Length); fs.Close(); HttpContext.Current.Response.ContentType = "application/pdf"; HttpContext.Current.Response.AddHeader("Content-Disposition", $"attachment;filename={fileName}"); HttpContext.Current.Response.TransmitFile(filePath); HttpContext.Current.Response.End(); }