Click here to Skip to main content
15,905,563 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Frnds,
When I click a button crystal report is converted to pdf and getting downloading by using below code..Before downloading i have to show it in new tab ..How to do it...Also I have to show multiple reports at a time open in multiple tabs.

C#
ReportDocument rptDoc = new ReportDocument();
                                       rptDoc.Load(Server.MapPath("/Reports/RPT/" + RepName));
                                       rptDoc.Refresh();
                                       rptDoc.SetDataSource(dtReportData);
                                       CrystalReportViewer1.ReportSource = rptDoc;

               BinaryReader stream = new BinaryReader(rptDoc.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat));
               Response.ClearContent();
               Response.ClearHeaders();
               Response.ContentType = "application/pdf";
               Response.AddHeader("content-disposition", "attachment; filename=" + ReportName + ".pdf");
               Response.AddHeader("content-length", stream.BaseStream.Length.ToString());
               Response.BinaryWrite(stream.ReadBytes(Convert.ToInt32(stream.BaseStream.Length)));
               Response.Flush();
               Response.Close();


Thanks
Suresh
ASAP...
Posted
Updated 21-Jan-13 17:34pm
v2

1 solution

Use crystal report viewer to display crystal reports.

C#
crystalreport1 objReport=new crystalreport1();
crystalreportviewer1.reportsource=objReport;
 
Share this answer
 
v2
Comments
itsureshuk 21-Jan-13 23:46pm    
where i have to give this line...which lines i have to remove
josh-jw 22-Jan-13 0:02am    
in ur new tab. and put downloading code in button click.(button in new tab).if you use crystal report 13, there is a default option for saving report in different format like pdf ,word etc.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900