Solved

Print column headings in a Crystal report export to csv

Posted on 2006-11-29
11
2,784 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 101

Expert Comment

by:mlmcc
ID: 18039734
I think that is the way the export to CSV works.

mlmcc
0
 
LVL 2

Assisted Solution

by:badstink
badstink earned 350 total points
ID: 18039827
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
ID: 18039844
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
On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

 

Author Comment

by:rrtraverse
ID: 18039988
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
ID: 18040344
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
 
LVL 26

Expert Comment

by:Kurt Reinhardt
ID: 18040665
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
ID: 18040763
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
ID: 18040926
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
ID: 18041109
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
ID: 18041510
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
ID: 18041568
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

Enroll in July's Course of the Month

July's Course of the Month is now available! Enroll to learn HTML5 and prepare for certification. It's free for Premium Members, Team Accounts, and Qualified Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

630 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