The topics that we have covered here are :
2) Getting a feel of it - Using an existing Crystal Report file in your .aspx page
3) Crystal Reports Walkthrough - using the Pull Model
4) Crystal Reports Walkthrough - using the Push Model
5) Exporting the Report file into other formats
Crystal Report comes in various flavors and the one that is required for building reports for .NET is "".Ã It exposes a rich programming model with which we could manipulate its properties and methods during runtime.Ã If you are developing your .NET applications using Visual Studio .NET then you wonÃ¢â¬â¢t have to install any additional software as it is already built into Visual Studio .NET.
---- Advantages -----
Some of the major advantages of using are :
- Rapid report development
- Can extend it to complicated reports with interactive charts
- Exposes a report object model using which it can interact with other controls on the web form
- Can programmatically export the reports into widely used formats like .pdf, .doc, .xls, .html and .rtf
---- The Architecture ----
The various components that make up a simple implementation of Crystal Report as a 2-tier architecture, required for web applications are
The Client :
The client only needs a browser to access the reports which are embedded into the .aspx pages.
The Web Server hosts the :
- Crystal Report Engine (CREngine.dll)
Along with other tasks like merging the data with the report file, exporting reports into different formats, etc., it is the Report Engine that converts your Crystal Report into plain HTML that is passed on to your .aspx page.
- Crystal Report Designer (CRDesigner.dll)
The reports are created from scratch using the Crystal Report Designer, with which you could design the titles, insert data, formulas, charts, sub-reports, etc.
- The .rpt Report file
The first step to implement a report into your web application would be to create it using the Crystal Report Designer interface.Ã You will find some ready-made .rpt samples provided with the default installation.
- The Data Source
The way your .rpt file gets the data depends on which method you choose. You can choose to make Crystal Report itself to fetch your data without writing any code for it or you can choose to manually populate a dataset and pass it on to the report file. We will look at the various possibilities a little later in this article.
- Crystal Report Viewer web form Control (CRWebFormViewer.dll)
The Crystal Report Viewer control is a web form control that can be inserted into your .aspx page.Ã It can be thought of as a container that hosts the report on the .aspx page.Ã
Note : In a more complex implementation, the reporting server and the web server could be on different physical servers, where the web server would make an HTTP request to the reporting server.Ã The Crystal Reports could also be implemented as a web service.
---- Implementation Models -----
Fetching the data for the Crystal Report could be done by using any of the following methods :
- Pull Model :
where in Crystal Report handles the connection to the database using the specified driver and populates the report with the data, when requested.
- Push Model :
where it is the developer who has to write code to handle the connection and populate the dataset, and pass it on to the report.Ã The performance can be optimized in this manner by using connection sharing and manually limiting the number of records that are passed on to the report.
---- Report Types ----
Crystal Report Designer can load reports that are included into the project as well as those that are independent of the project.
- Strongly-typed Report :
When you add a report file into the project, it becomes a Ã¢â¬Ëstrongly-typedÃ¢â¬â¢ report. In this case, you will have the advantage of directly creating an instance of the report object, which could reduce a few lines of code, and caching it to improve performance. The related .vb
file, which is hidden, can be viewed using the editorÃ¢â¬â¢s Ã¢â¬Ëshow all filesÃ¢â¬â¢ icon in the Solution Explorer.Ã
- Un-Typed Report :
Those reports that are not included into the project are Ã¢â¬Ëun-typedÃ¢â¬â¢ reports.Ã In this case, you will have to create an instance of the Crystal Report EngineÃ¢â¬â¢s 'ReportDocument' object and manually load the report into it.
---- Other things you should know ----
- Though the Crystal Report Viewer control comes with some cool in-built options like zooming, page navigation, etc., it does not have a custom print option. You will have to depend on the browserÃ¢â¬â¢s print feature.
- An un-registered copy of will remain active only for the first 30 uses, after which the Ã¢â¬ËsaveÃ¢â¬â¢ option will be disabled.Ã To avoid this, all you have to do is register the product with www.crystaldecisions.com
for which you are not charged.
- The default installation will service only 5 concurrent users. To support more users, you will have to buy additional licenses from www.crystalDecisions.com
GETTING A FEEL OF IT Ã¢â¬â USING AN EXISTING CRYSTAL REPORT FILE IN YOUR .aspx PAGE
Lets take a look at how we could get this done the fast way to get a feel of how a Crystal Report file would look like in your web form.
1) Drag and drop the "Crystal Report Viewer" from the web forms tool box on to the .aspx page