Skip to Content

Problems with report header exporting to CSV

When exporting to character-separated value (CSV) format, the page header appears at the beginning of each record, instead of just once at the beginning of the CSV file.

That is the premise in KB Article #1196142 . In my case, the column headers were in the Report Header rather than the page header. However, I tried implementing the fix as described (running XI 11.0.0.2812) and it didn't seem to fix the problem. Specifically, I created the fake page header formula and built a group off it, then moved my Report Header content to the new group header.

The article says I should next create the following registry sub-key:

HKEY_LOCAL_MACHINE\Software\Business Objects\Suite 11.0\Crystal Reports\Export\CSV\AreaExportOptions

Maybe I misunderstood the sub-key. I did not have the CSV sub-key, so I created it. Then I created a DWORD value named AreaExportOptions. I also tried creating a AreaExportOptions key word, but then didn't know what to name the DWORD value.

Upgrading Crystal is not an option as the company's product deployment is too extensive.

Any ideas?

Fuskie

Who has not run up against this before...

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • Best Answer
    avatar image
    Former Member
    Jun 17, 2010 at 09:15 AM

    hi

    i have 4 report headers, each header section has one subreport when i export these reports to .csv format it doesn't populated simply shows blank page. i struck with this problem please guide me to solve this problem.

    Edited by: rahulbo on Jun 17, 2010 2:45 PM

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member David Deitch

      Reports formatted with group headers and/or footers don't really do well when exported to CSV. A CSV file, by definition, will display the same information columns in EVERY row... So there won't be a group header row followed by detailed rows.

      If you want to export to CSV, export the detail rows only.

      HTH,

      Jason

  • avatar image
    Former Member
    Oct 09, 2015 at 02:47 PM

    I know this is an old post, but thought this might help someone else.  I tried the registry change, but could never get it to work.  I fought with the CSV issue for several days and finally found a decent solution that seems to be fast and reliable.  The process exports the report to an XML stream that is read directly into a dataset.  This dataset is then used to create the CSV file.

    NOTE:  In your report file, make place your header labels in the ReportHeader section of the report.

    Here's the code I used:

    Private Sub ExportToCSV(crDoc As ReportDocument, strOutputFile As String)

            Try

                Dim sbLine As New StringBuilder

                Dim ds As New Data.DataSet

                'read the XML stream directly into dataset

                ds.ReadXml(crDoc.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.Xml))

                Using outputFile = File.CreateText(strOutputFile)

                    'write the header row

                    For Each dr As DataRow In ds.Tables("Text").Rows

                        sbLine.Append(String.Format("""{0}"",", dr.Item("TextValue")))

                    Next

                    outputFile.WriteLine(sbLine.ToString().TrimEnd(","c))

                    sbLine = New StringBuilder

                    'write the detail rows

                    For i As Integer = 0 To ds.Tables("Field").Rows.Count - 1 Step ds.Tables("Text").Rows.Count

                        For ii As Integer = 0 To ds.Tables("Text").Rows.Count - 1

                            sbLine.Append(String.Format("""{0}"",", ds.Tables("Field").Rows(i + ii).Item("FormattedValue")))

                        Next

                        outputFile.WriteLine(sbLine.ToString().TrimEnd(","c))

                        sbLine = New StringBuilder

                    Next

                End Using

            Catch ex As Exception

            End Try

        End Sub

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jun 16, 2010 at 07:49 AM

    I have the same problem in CR 2008 SP2.

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 13, 2015 at 09:13 PM

    Thanks for the follow-up.  I've moved on a couple jobs since the original post but hopefully others will benefit!

    David Deitch
    Crystal Reports Developer
    Host, Crystal Reports and Crystal Reports Professionals of Atlanta groups on LinkedIn
    Co-Moderator, Crystal Reports Users Group and Crystal Users groups on Yahoo Groups


    Email: david.deitch@gisatl.org
    LinkedIn: http://www.linkedin.com/in/ddeitch
    Twitter: @David_Deitch
    Facebook: http://facebook.com/CrystalConnectionsAtlanta

    Add comment
    10|10000 characters needed characters exceeded