Crystal Report Export Pull Method
Use the following code for exporting crystal directly to pdf document.Step 1: Create a Class Libray based project and create crystal report in the library. and compile it. (project dll file is created)Step 2 : Create a simple asp.net web site and include the dll file of the above project.Step 3:Use the following code, which uses the report and generates the pdf. CrystalReport1 c = new CrystalReport1();
c.RecordSelectionFormula = "{Users.Username}='admin'";
CrystalDecisions.Shared.DiskFileDestinationOptions desoptions=new CrystalDecisions.Shared.DiskFileDestinationOptions ();
desoptions.DiskFileName = Server.MapPath("a1.pdf");
CrystalDecisions.Shared.ExportOptions exp=new CrystalDecisions.Shared.ExportOptions (); exp.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
exp.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile ;
exp.ExportDestinationOptions = desoptions;
c.Export(exp);
Response.Redirect("A1.pdf");
Use the following code for exporting crystal directly to pdf document.
Step 1: Create a Class Libray based project and create crystal report in the library. and compile it. (project dll file is created)
Step 2 : Create a simple asp.net web site and include the dll file of the above project.
Step 3:Use the following code, which uses the report and generates the pdf.
CrystalReport1 c = new CrystalReport1();
c.RecordSelectionFormula = "{Users.Username}='admin'";
c.RecordSelectionFormula = "{Users.Username}='admin'";
CrystalDecisions.Shared.DiskFileDestinationOptions desoptions=new CrystalDecisions.Shared.DiskFileDestinationOptions ();
desoptions.DiskFileName = Server.MapPath("a1.pdf");
CrystalDecisions.Shared.ExportOptions exp=new CrystalDecisions.Shared.ExportOptions ();
exp.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;
exp.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile ;
exp.ExportDestinationOptions = desoptions;
c.Export(exp);
Response.Redirect("A1.pdf");
exp.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile ;
exp.ExportDestinationOptions = desoptions;
c.Export(exp);
Response.Redirect("A1.pdf");
0 comments