Hi Don, I tried to export to RPT, but somehow the output file cannot be opened. I modified the existing code for PDF export. It works for PDF prefecture. I didn't make any change on the report. I just tried to load and export the same file.
CrystalDecisions.CrystalReports.Engine.ReportDocument cryRpt = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
cryRpt.Load(tempaltePath);
cryRpt.SetParameterValue("DATASET_ID", DatasetId);
try
{
var crDiskFileDestinationOptions = new DiskFileDestinationOptions { DiskFileName = @"C:\test.rpt" }; // It was .pdf
var crExportOptions = cryRpt.ExportOptions;
{
crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
crExportOptions.ExportFormatType = ExportFormatType.CrystalReport; // it was ExportFormatType.PortableDocFormat
crExportOptions.DestinationOptions = crDiskFileDestinationOptions;
crExportOptions.FormatOptions = new ExportOptions(); // it was PdfRtfWordFormatOptions()
}
cryRpt.Export();
}
catch (Exception ex)
{
Console.WriteLine(ex.ToString());
}