Symptom
When using Crystal API to export to CSV format, the output is different compare to the result from Crystal Reports 2016 designer.
Environment
- SAP Crystal Reports for Visual Studio
- SAP Crystal Reports 2016
Reproducing the Issue
Step 1:Using Crystal Reports 2016 designer and use attached report, then export to CSV format with the following options:
-
Mode: standard mode
-
Report and Page sections:
-
Export + Isolate
-
Group sections: Export + Isolate
Step 2:Compare the output between Crystal designer and API output from designer has 3 lines, but only have 2 lines from code below:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using CrystalDecisions.CrystalReports.Engine;
using System.IO;
using CrystalDecisions.Shared;
using CrystalDecisions.ReportAppServer.ClientDoc;
using RDM = CrystalDecisions.ReportAppServer.ReportDefModel;
using CrystalDecisions.ReportAppServer.Controllers;
using CrystalDecisions.ReportAppServer.DataDefModel;
using System.Threading;
namespace CrystalRasTest
{
class Program
{
private static ReportDocument m_report = null;
static void Main(string[] args)
{
m_report = new ReportDocument();
string reportFilePath = @"AnyNodata.rpt";
m_report.Load(reportFilePath, OpenReportMethod.OpenReportByDefault);
try
{
string outputFileName = @"output.rpt";
if (File.Exists(outputFileName))
{
File.Delete(outputFileName);
}
ExportOptions exportOptions = m_report.ExportOptions;
exportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
DiskFileDestinationOptions deskOpt = new DiskFileDestinationOptions();
deskOpt.DiskFileName = outputFileName;
exportOptions.ExportDestinationOptions = deskOpt;
exportOptions.ExportFormatType = ExportFormatType.CrystalReport;
m_report.Export(exportOptions);
//exportOptions.ExportFormatType = ExportFormatType.CharacterSeparatedValues;
//CharacterSeparatedValuesFormatOptions csvFormatOpt4 = ExportOptions.CreateCharacterSeparatedValuesFormatOptions();
//csvFormatOpt4.ExportMode = CsvExportMode.Standard;
//csvFormatOpt4.ReportSectionsOption = CsvExportSectionsOption.ExportIsolated; // //Export, DoNotExport, ExportIsolated
//csvFormatOpt4.GroupSectionsOption = CsvExportSectionsOption.ExportIsolated;
//csvFormatOpt4.Delimiter = string.Empty;
//exportOptions.ExportFormatOptions = csvFormatOpt4;
//m_report.Export(exportOptions);
}
catch (Exception e)
{
Console.WriteLine(e.Message);
Console.Read();
}
finally
{
m_report.Close();
m_report.Dispose();
}
// Console.ReadLine();
}
}
}
Resolution
See SAP Note 2399143 - When exporting a report with no data to CSV format from Crystal Reports, it generates one line of commas.
Issue was resolved in CR for VS SP 20 and above.
NOTE: tested with SP 24 and it appears to be broken again
Keywords
export to csv, cr for vs , KBA , BI-DEV-NET , BI Software Development Kits (SDKs) - .NET or Other , Problem
Product
Attachments
LDDH002X_CR16_Nodata.RPT |