Solved

Print column headings in a Crystal report export to csv

Posted on 2006-11-29
11
2,453 Views
Last Modified: 2012-06-27
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.
0
Comment
Question by:rrtraverse
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 100

Expert Comment

by:mlmcc
Comment Utility
I think that is the way the export to CSV works.

mlmcc
0
 
LVL 2

Assisted Solution

by:badstink
badstink earned 350 total points
Comment Utility
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
 
LVL 2

Expert Comment

by:badstink
Comment Utility
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
 

Author Comment

by:rrtraverse
Comment Utility
My file has to be a csv export, for import to another application database.  So, no way to have column headings?
0
 
LVL 2

Expert Comment

by:badstink
Comment Utility
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
LVL 26

Expert Comment

by:Kurt Reinhardt
Comment Utility
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
 

Author Comment

by:rrtraverse
Comment Utility
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
 
LVL 26

Accepted Solution

by:
Kurt Reinhardt earned 150 total points
Comment Utility
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
 
LVL 2

Expert Comment

by:badstink
Comment Utility
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
 
LVL 26

Expert Comment

by:Kurt Reinhardt
Comment Utility
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
 
LVL 2

Expert Comment

by:badstink
Comment Utility
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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
There have always been a lot of questions related to when Crystal Reports evaluates report components (such as formulas, summaries, cross-tabs, charts, to name a few examples). Crystal Reports uses a two-pass reporting process to provide greater …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now