Crystal Reports gives you two ways of delivering reports. The first way is exporting them to different formats and file types. For example, you could export reports as PDF or MS Word files. You could also export them as email attachments. The second way of delivering reports is by deploying them with your application. This involves modifying the setup files so that the reports and related libraries are included on the destination computer. This chapter covers both exporting and deploying reports.
Exporting Reports
Printing and previewing reports is a great way of presenting data to users. But there is one big problem: the user has to have a copy of your application to do it. If you want to show someone what a report looks like, you can’t email them your application or ask everyone to sit at your computer. That is where exporting comes in. You can export reports in a variety of formats that are displayed by common applications that most people already have (Adobe Acrobat, Excel, HTML, etc.). This lets people see and understand your data without having a copy of the application on their computer. For example, the PDF format is the most common way of presenting data via the web. In fact, it has become the de facto standard and most users already have the Adobe Acrobat viewer installed on their computer. If you want to deliver reports that let users work with the data so that it is dynamic, you can export them to an Excel spreadsheet and give your users the ability to perform more advanced data analysis.
In one respect, exporting a report could seem like a frivolous task. Consider that a report is just output data that you had to assimilate with your code. Rather than generate a report, you could skip that step entirely and use a SQL query to export the raw data into another table or as XML. However, using Crystal Reports gives you many advantages. The most obvious advantage is that it has the export functionality built-in and this saves you time programming. A less obvious benefit is that it gives you the ability to quickly customize how the data is presented. Use the powerful report engine to perform the sorting and grouping and other functionality without having to worry about the implementation details. Without a doubt, being able to export report data to different formats is a very powerful feature.
Crystal Reports gives you many different formats for exporting your reports. They are as follows: MS Excel, HTML 3.2/4.0, PDF, Rich Text, MS Word, Microsoft Mail (MAPI), and Exchange Folder.
There are two ways to export a report. The first is using the built-in export capabilities of the viewer control. The second is to write the code to export the report. Although the second method is more work, you’ll see in a later section that it gives you more control over the exporting process.