cancel
Showing results for 
Search instead for 
Did you mean: 

Export report into CSV with headers

former_member1012208
Participant
0 Kudos
194

I am using the following code to export a report into csv. But this code only works well, if I don't have field headers defined.
If my report has header info in the report header, when exporting, Crystal inserts the header information at the begining of each record.
I only need it once atr the top of the report, not at the start of each record.
Does anyone know how to get it exported only once at the start of the report?

Dim myReport As New ReportDocument
myReport.Load(ReportNameAndPath)

Dim CrExportOptions As ExportOptions
Dim CrDiskFileDestinationOptions As New DiskFileDestinationOptions()
Dim CrFormatTypeOptions As New CharacterSeparatedValuesFormatOptions ' ExcelFormatOptions
CrFormatTypeOptions.SeparatorText = ""
CrFormatTypeOptions.Delimiter = ""
CrFormatTypeOptions.ExportMode = CsvExportMode.Standard
CrFormatTypeOptions.ReportSectionsOption = CsvExportSectionsOption.Export
CrFormatTypeOptions.GroupSectionsOption = CsvExportSectionsOption.Export
CrDiskFileDestinationOptions.DiskFileName = tmpExcelFile
CrExportOptions = myReport.ExportOptions
With CrExportOptions
     .ExportDestinationType = ExportDestinationType.DiskFile
     .ExportFormatType = ExportFormatType.CharacterSeparatedValues
     .DestinationOptions = CrDiskFileDestinationOptions
     .FormatOptions = CrFormatTypeOptions
End With
myReport.Export()

I am using VS2010 and Crystal reports 2008

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

VS 2010 and Crystal 2008 runtime is not supported platform, should work but no fixes available. Try Cr for Vs 2010.

What happens when you export from the Designer?

Try the latest Service Packs for CR 2008 to see if that helps, if not then try CR for Vs 2010 SP 4.

Don

former_member1012208
Participant
0 Kudos

I tried with the CR version for VS 2010 and got the same results. Exporting from the designer works without any issues. I even tried the SPs but still no luck.

0 Kudos

Hi Don,

What are these 2 variables being set to?

CrFormatTypeOptions.ReportSectionsOption = CsvExportSectionsOption.Export

CrFormatTypeOptions.GroupSectionsOption = CsvExportSectionsOption.Export

Do you have a sample report with saved data I can test with?

Go into the Advanced Editor and rename the report to *.txt, then you can attach it to the post. must be less than 1 meg. And rename and attach what the output from the designer looks like.

Don

Answers (0)