Skip to Content

We have to design a report according to a particular export format viz. PDF, Excel, CSV, etc. A report designed for the PDF format will not be exported correctly to Excel format and vice versa. The below steps will explain how to create a report in Crystal Reports, which can be exported to the respective format correctly.

For this document we will cover PDF, CSV and Excel formats.

Steps of work around:

Step 1: Create an extra parameter in report level which is default parameter @Export_Type and the values as EXCEL, CSV and PDF. Depending on the selected

            parameter value the report will be formatted in the desired format.

Step 2: Design a report as per requirements for PDF format.

Step 3: We will divide each section in the report into 3 parts. The first part will be used to show data fields in PDF format, 2nd part will be used to show data

            fields in Excel format and the 3rd part will be used to show the report in CSV format.

Step 4:  Right click on each section in the report and select “Insert section below”. This will divide each section in a, b, c parts. Ex. Details a, Details b,

                Details c. Refer the snap-shot below:

                s1.JPG

s2.JPG

Step 5: Create a report level static parameter named as “Export_Type” with values as EXCEL, CSV and PDF. Refer the snap-shot below:

     s3.JPG

Step 6: Now we need to enable/disable the respective sections as per the “Export_Type” parameter value. Use “Section Expert” to write a suppression formula

           for each section in the report. Refer the snap-shot & the formula below:

               s4.JPG

             

       For PDF      For Excel For CSV

if {?Export_Type}=”EXCEL” Then

    True

Else if {?Export_Type}”CSV” Then

    True

Else if {?Export_Type}=”PDF” Then

    False;

if {?Export_Type}=”EXCEL” Then

     False

Else if {?Export_Type}=”CSV” Then

     True

Else if {?Export_Type}=”PDF” Then

     True;

if {?Export_Type}=”EXCEL” Then

    True

Else if {?Export_Type}=”CSV” Then

    False

Else if {?Export_Type}=”PDF” Then

     True;

Step 7: The formula in the Step 6 has to be placed in the appropriate section.

Step 8: Place all the report objects/data fields in all the section by creating copies of them and format them as per the respective section.

Step 9: Refresh the report by passing the appropriate “Export_type” parameter value and see that your report will be formatted according to it.

To report this post you need to login first.

16 Comments

You must be Logged on to comment or reply to a post.

  1. Vijesh Chandra

    Thats too good.

    Rajesh, I want to ask something. I have many Crystal Report which conatains groups on fields to compute overall values. Here the thing is that, we have Report Header in 2 sections. section a contains the header which is merger of 2 header of section b. In this case when export the report as excel data, sections a header comes first and then sections b’s header, hence changed all formatting of the report.

    Can you please put some light if the above solution given by you will help me out.

    (0) 
  2. Ryan Liljestrand

    When creating the separate sections, I find it helpful to add a label in a small font size that specifies what the section is for (i.e. “C” for CSV, “X” for Excel or “P” for PDF). I then set this label to be suppressed.  This way, it shows up on the report designer canvas without appearing in the rendered report.

    (0) 
      1. Vijesh Chandra

        Hi Rajesh,

        I am not able to attach images as “Insert Image” is disabled for me. Can you please provide your mail id so I can forward the same there?

        Vijesh

        (0) 

Leave a Reply