Export crystal report to pdf directly
the given code directly export to pdf format.
store your query result in dataset 'ds'
//Declare Reportdocument Object
ReportDocument rpt=new ReportDocument();
//set a ReportPath and assign the dataset to reportdocument object
rpt.Load(Server.MapPath("Report1.rpt"));
rpt.SetDataSource(ds);
//assign the values to crystal report viewer
CrystalReportViewer1.ReportSource = rpt;
CrystalReportViewer1.DataBind();
//Exporting PDF
MemoryStream oStream; // using System.IO
oStream = (MemoryStream)
rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.BinaryWrite(oStream.ToArray());
Response.End();
store your query result in dataset 'ds'
//Declare Reportdocument Object
ReportDocument rpt=new ReportDocument();
//set a ReportPath and assign the dataset to reportdocument object
rpt.Load(Server.MapPath("Report1.rpt"));
rpt.SetDataSource(ds);
//assign the values to crystal report viewer
CrystalReportViewer1.ReportSource = rpt;
CrystalReportViewer1.DataBind();
//Exporting PDF
MemoryStream oStream; // using System.IO
oStream = (MemoryStream)
rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat);
Response.Clear();
Response.Buffer = true;
Response.ContentType = "application/pdf";
Response.BinaryWrite(oStream.ToArray());
Response.End();
Labels: Crystal Reports

0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home