Print column headings in a Crystal report export to csv

Is there a way to print column headings as well as data in a Crystal Report that is being exported to a csv file.  I tried putting the column names in the page header and the report header sections and when I export to csv file, the headings come out on the same line as the data.
rrtraverseAsked:
Who is Participating?
 
Kurt ReinhardtConnect With a Mentor Sr. Business Intelligence Consultant/ArchitectCommented:
Now I understand.  If this is simply for the purpose of testing, then export the report twice - once to .csv for the import and once to Excel in order to compare results to ensure that the right elements ended up in the appropriate columns.  Since you can export the report more than once into different formats without refreshing the data you should be assured that the data didn't change between the exports.

~Kurt
0
 
mlmccCommented:
I think that is the way the export to CSV works.

mlmcc
0
 
badstinkConnect With a Mentor Commented:
Hi,

I am using Crystal Reports XI Release 2.  I experienced the same results as you did when exporting to CSV.

If you ultimately want an Excel output file you can export the report data to the format "Microsoft Excel 97-2000 - Data only (XLS)".  When the Excel Format Options pop-up appears choose "Custom" and then check the Export Page Header and Page Footer option.

Jeff
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
badstinkCommented:
I failed to mention that you can export to Excel (as described above), then using Excel you can export to CSV.  This gives you the desired results but requires the extra effort.

Jeff
0
 
rrtraverseAuthor Commented:
My file has to be a csv export, for import to another application database.  So, no way to have column headings?
0
 
badstinkCommented:
I know of another trick, if you have the ability to modify your query so that it always returns an extra row of data.

For example,

Select  0 flag_isthisdata,
           NULL field1,
           NULL field2,
           etc
from    dual
UNION  1 flag_isthisdata,
           field1,
           field2,
           etc
from    yourtable

This query will always return 1 extra row of data.

In your report, do the following:

1) sort on the flag_isthisdata field so that the extra row always occurs first
2) add a new Details section so that you have Details A and Details B
3) Suppress Details A if flag_isthisdata = 1
4) Suppress Details B if flag_isthisdata = 0
5) In Details A, add text fields containing your column heading values
6) In Details B, include your database fields and/or formulas that you wish to export

When you export to CSV *do not* export the report and page sections.

This should do the trick.

Jeff
0
 
Kurt ReinhardtSr. Business Intelligence Consultant/ArchitectCommented:
This is how .csv files work.  .csv files are supposed to be data dumps.  They aren't supposed to have headers, because they're generally intended to be used to load data into another system.  Case in point, that's what you're using it for.  Since you're using it to load data into a database, why do you need headers?  Are you importing the header row into the database, too?  The table should already have predefined field descriptions.  Headers are only necessary if you're going to view the file in another format, such as MS Excel.

~Kurt
0
 
rrtraverseAuthor Commented:
You are absolutely correct, except that this is a new interface file and the person testing the interface wanted column headings to match back to the intended database.
0
 
badstinkCommented:
My last suggestion will provide column headings on the first row of output only as long as you disable the Export Report Page Sections option.

The sample SQL I provided is for Oracle.  You can also create a database view instead and then query the view from your report.

Sample SQL to create DB view:

Create or replace view yourview as
Select  0 flag_isthisdata,
           NULL yourfield1,
           NULL yourfield2,
           NULL yourfield3,
           etc
from    dual
UNION  1 flag_isthisdata,
           yourfield1,
           yourfield2,
           yourfield3,
           etc
from    yourtable
;

If you use the database view as described above, use the Database -> Set Database Location feature to change the report from your old database table to the new database view.

I hope you give this a try as it is a relatively easy way to get what you desire.
0
 
Kurt ReinhardtSr. Business Intelligence Consultant/ArchitectCommented:
badstink,

In my opinion, your suggestions are creative and would work very well if the questioner needed a permanent solution.  In this case, I think it creates an unnecessary element of complexity to the report, but I think it's definitely valuable to the thread for future searches.  Good ideas:)

~Kurt
0
 
badstinkCommented:
Thank you for the compliment Kurt.

My initial proposals (including comment dated 11/29/2006 11:40AM PST) described the simpler solution of performing a double export but the author did not accept it presumedly because he needed to "import to another application database".   Hence the additional solution with element of complexity.
0
All Courses

From novice to tech pro — start learning today.