SAP Knowledge Base Article - Public

1586586 - Exporting to character-separated value (CSV) format, Page Header appears at the beginning of each record

Symptom

  • Using the InProc RAS SDK for VS .NET
  • Exporting to character-separated value (CSV) format, Page Header appears at the beginning of each record
  • Page Header should only appear once at the beginning of the CSV file

Environment

Resolution

  • The following code will ensure that the Page Header is only exported at the beginning of the CSV file:
Sub exportToCsv_Ras(ByVal fileName$, ByVal charStringDelimiter$, ByVal charFieldDelimiter$)
 Dim exportOptions As New CrystalDecisions.ReportAppServer.ReportDefModel.ExportOptions
 Dim CSVexportOptions As New CharacterSeparatedValuesExportFormatOptions
 exportOptions.ExportFormatType = CrReportExportFormatEnum.crReportExportFormatCharacterSeparatedValues
 CSVexportOptions.Delimiter = charStringDelimiter$
 CSVexportOptions.ExportMode = CrCSVExportModeEnum.crCSVExportModeStandard
 CSVexportOptions.ReportSectionsOption = CrCSVExportSectionsOptionEnum.crCSVExportSectionsOptionExport
 CSVexportOptions.Separator = charFieldDelimiter$
 'Following is the critical line of code
 CSVexportOptions.GroupSectionsOption = CrCSVExportSectionsOptionEnum.crCSVExportSectionsOptionExportIsolated
 'Set the export format options with the page range we just set.
 exportOptions.FormatOptions = CSVexportOptions
 Dim oByte() As Byte = CType(GlobalSettings.getInstance().m_RasDoc.PrintOutputController.ExportEx(exportOptions).ByteArray, Byte())
 Dim fout_csv As System.IO.FileStream = New System.IO.FileStream(fileName$, FileMode.Create)
 fout_csv.Write(oByte, 0, oByte.Length - 1)
 fout_csv.Close()
End Sub

Keywords

KBA , BI-DEV-NET-SDK , .NET SDK / COM SDK , How To

Product

SAP Crystal Reports, developer version for Microsoft Visual Studio