The Crystal report has a feature to export data to different file formats without viewing report on CrystalReportViewer. Here I like to demonstrate, how we can export report to different file formats by programmatically. Hence we will not show the report on the screen, but at the same time we can save the report file format.


The purpose of this article is to illustrate how to export reports different files types. As I mentioned my earlier articles reporting is most important, may be users need reports in different file types. Crystal report also has feature to export report to various file formats.

1. SQL Server 2005
2. Visual studio 2005/2008
3. Crystal report

Before start to design a report, you need a database which is going to use by report. Here I have designed a small database for this demonstration.

The created database name is “HouseRental” with “HouseOwnerInfo” table. There are eight columns in the “HouseOwnerInfo. Let us design a report to this table, get ‘House owners’ summary report’ which is using date parameter to process the report.

Note: The database design is only for demonstration purpose.

Let us start designing the report. For that, there are two standard ways. The first way is we can use the crystal report and second one is we can use the Visual studio. Here I have used Visual Studio since I prefer that.

First open Visual studio 2008 or 2005 and create new web project called “ExportReportToDiffFileFormat”. Then right click the project and select Add New Item from the bar.Select Crystal Report from the templates list window. When you select crystal report, give a meaningful name to the report. Here I have given “DiffFileFormatRpt.rpt”. Then click OK button.

Once you click the OK button, you will get a welcome window as shown by the following figure.

Keep the Standard report format and click OK button.
Then you need to create the database connection to access tables within the database. Once you click OK button, system gives a window to select the connection type as shown below.

This demonstration report is to work with SQL Server 2005 database. So you need to select SQL native client as provider (As above figure shows).
Then click Next button, to continue report creation process. Then you need to assign details of SQL Server and user credential to access the database from the report. Then you need to expand current connection tag, select your database connection then select the relevant table as shown by the following figure.

Then click Next button to continue. There you need to select fields from selected tables to design report as shown by the following figure.

Then click Next button. Now you have done necessary effort and finished the final step. As a result, you will get report like this.

Let us work with some coding to archive our goal.

We have created a report in the earlier steps, now we need to write code for export report to different files type according to file types of user’s selection.

Now design a straightforward user interface to select export file format.

Let us write code for Button click and form load event.
First we need to load all file types to drop-down list on the form load.

Here we have just loaded get enumeration for all supportable formats by the crystal report and make it to a string collection and then bind to the drop down list.

Then write code for button click event, to export report to selected file format. (from the drop down list)

Here we have loaded report from the source file and then we need to set database logon to system. After that you need to call one of the methods in the report object, to export report.

Case CrystalDecisions.Shared.ExportFormatType.Excel:

Then write switch case statement to switch path according to the file type selection.

Now build the application and run. Then select a report format and click ‘Make it’ button to process.

Finally here are few sample outputs.


In this article we have learned to convert reports to different formats with CrystalReportViewer. Now you know the conversion is easy with crystal report and .net



- B.Sc. degree in Computer Science.
- 4+ years experience in, adn JAVA.
- Obsessed in OOP style design and programming.
- Designing and developing Network security tools.
- Designing and developing a client/server application for sharing files among users in a
  way other than FTP protocol.
- Designing and implementing GSM gateway applications and bulk messaging.
- Windows Mobile and Symbian Programming
- Having knowledge with ERP solutions

The summary of my skills:
C#, VB.Net#,, VC++, Java, WPF,WCF, SilverLight,Oracle,PL/SQL, SQL Server, MS Access

My Web Blogs

[Download Sample]