SAP Knowledge Base Article - Public

2351487 - Export to CSV from the Windows Form or WPF viewer or in code does not use the Delimiter or Separator in Crystal Reports for Visual Studio WPF .NET application

Symptom

Using CR for VS SP 15 or SP 17 seems to have changed the export to CSV output, it no longer uses the Delimiter or separator saved in the RPT file.

Environment

  • Crystal Reports for Visual Studio SP 15
  • Crystal Reports for Visual Studio SP 17

Reproducing the Issue

Export any report from the viewer control and select CSV as the export option.

Resolution

This issue has been esclated to R&D for a fix and should be in SP 18 due out end of September, 2016

Work around:

Create an Export Button and use the following code, mode as required:

CrystalDecisions.CrystalReports.Engine.ReportDocument doc = new CrystalDecisions.CrystalReports.Engine.ReportDocument();
doc.Load(@"D:\Reports\integratedSecurityMSSQLWithData.rpt");

CrystalDecisions.Shared.CharacterSeparatedValuesFormatOptions csvExpOpts = new CrystalDecisions.Shared.CharacterSeparatedValuesFormatOptions();
CrystalDecisions.Shared.ExportOptions exportOpts = new CrystalDecisions.Shared.ExportOptions();
CrystalDecisions.Shared.DiskFileDestinationOptions diskOpts = CrystalDecisions.Shared.ExportOptions.CreateDiskFileDestinationOptions();

diskOpts.DiskFileName = @"d:\reports\CSVExportNoDelimitorseparator.csv";

csvExpOpts = new CharacterSeparatedValuesFormatOptions();

csvExpOpts.ExportMode = CsvExportMode.Standard;
//csvExpOpts.GroupSectionsOption = CsvExportSectionsOption.ExportIsolated;
//csvExpOpts.ReportSectionsOption = CsvExportSectionsOption.DoNotExport;
csvExpOpts.SeparatorText = "#";
csvExpOpts.Delimiter = ",";

exportOpts.DestinationOptions = diskOpts;
exportOpts.ExportDestinationType = ExportDestinationType.DiskFile;
exportOpts.ExportFormatType = ExportFormatType.CharacterSeparatedValues;
exportOpts.ExportFormatOptions = csvExpOpts;

try
{
    doc.Export(exportOpts);
}
catch (Exception ex)
{
    MessageBox.Show(ex.Message);
    return;
}

Keywords

CR for VS, .NET, CSV, WPF, export to CSV , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio