Crystal Reports Online Training

Learn Online, Anytime, Anywhere

Step-by-step online tutorials.

3.02 Integration Options

Summary of report integration options

Whether you use the viewer control to preview reports or write the code to send them directory to the printer, there are many options for integrating reports into your application. They range from the simple drag-and-drop to the more complex coding techniques of working with the ReportDocument object model. The one you choose depends upon your needs as well as how comfortable you are working with the ReportDocument object model. Of course, the more code that you’re willing to write, the more functionality that you can give the user.

The following list is a quick summary of each reporting option available to you. This gives you an easy overview of what you can do and helps you decide which is best for you. Afterwards, each option is explained in more detail so that you can implement it in your own project. To start being productive right away, you should read through the following summaries and go directly to the section you need.

Smart Tasks Panel

A Smart Tasks panel is a set of shortcuts on the viewer control which automatically sets the properties you need. Use the Smart Tasks button in the top right corner of the viewer control to open the panel and quickly attach a report to your form. This requires zero coding and is the fastest way to integrate reports into your applications.

CrystalReportDocument Component

This component lets you add a report to a form without writing any code. You can have it point to any report and associate it with the viewer control. If you are using the Smart Tasks panel, this automatically gets added to your form and points to the report you selected.

In Visual Studio .NET 2005, The CrystalReportDocument component is called ReportDocment.

Non-Embedded Reports

Non-embedded reports let you load physical report files from your computer using a fully qualified filename. Since the reports are stored separately from your project, they can be shared among users via a common networked drive. Non-embedded reports can be used with the Smart Tasks option or by writing code For ASP.NET applications; this is your only option for using reports.

Embedded Reports

When adding a report to a Windows application, Visual Studio automatically creates a class to represent the report and includes it in your project files. This class inherits from the ReportDocument class. It is called an embedded report because it is part of your application. Updating a report requires recompiling and redistributing the application.

ReportDocument Class

If you don’t use the Smart Tasks panel to quickly attach reports to the viewer, you’re going to have to use the ReportDocument class to declare and instantiate a report object variable. Whether you use embedded or non-embedded reports, you are still working with the methods and properties of the ReportDocument class. Luckily, in its most simplistic form, it only takes a couple lines of code to instantiate a report and preview it. We’ll cover how to use the ReportDocument class in Part II of this book when we look at the details of advanced report customization during runtime.

Printing to the Printer

Crystal Reports doesn’t need the viewer control to print reports. You can send reports directly to the printer without requiring the user to preview it first. Although not as common, this is useful when the user has standard reports that get printed every month or when printing batch reports that are processed during off-hours. This involves more coding than using the viewer control. Just like the ReportDocument class, this is covered in Part II of this book since it involves writing code.

The following sections take each option and show you the exact steps for implementing each one in your application. Remember that you don’t have to read and understand each method. Each one is simply a different way of producing a report within your application. Focus on the one that meets your requirements and learn it first. Of course, it’s always good to understand all the options available to you, but you can come back to this chapter later if you feel that all this information is a bit overwhelming right now.