C# Crystal Reports Export to Pdf
You have to include two line in your C# Source Code.
using CrystalDecisions.CrystalReports.Engine; using CrystalDecisions.Shared;
try { ExportOptions CrExportOptions ; DiskFileDestinationOptions CrDiskFileDestinationOptions = new DiskFileDestinationOptions(); PdfRtfWordFormatOptions CrFormatTypeOptions = new PdfRtfWordFormatOptions(); CrDiskFileDestinationOptions.DiskFileName = "D:\\csharp.pdf"; CrExportOptions = cryRpt.ExportOptions; { CrExportOptions.ExportDestinationType = ExportDestinationType.DiskFile; CrExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat; CrExportOptions.DestinationOptions = CrDiskFileDestinationOptions; CrExportOptions.FormatOptions = CrFormatTypeOptions; } cryRpt.Export(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); }The Crystal Reports file path in your C# project files location, there you can see CrystalReport1.rpt . So give the full path name of Crystal Reports file like D:\projects\crystalreports\CrystalReport1.rpt When you run this program you will get the PDF file in your computer's D Drive
0 comments:
Post a Comment