cancel
Showing results for 
Search instead for 
Did you mean: 

Problems with report header exporting to CSV

Former Member
0 Kudos

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...

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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

Former Member
0 Kudos

>

> 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.

That is most likely a different issue. My experience is that sub-reports do not export very well to Excel or CSV files.

Fuskie

Who is hoping someone has applied this knowledge base article and can offer some clarification...

Former Member
0 Kudos

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

Answers (3)

Answers (3)

Former Member
0 Kudos

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

Former Member
0 Kudos

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

Former Member
0 Kudos

I have the same problem in CR 2008 SP2.