Home  |  FAQ  |  About  |  Contact  |  View Source   
 
SEARCH:
 
BROWSE:
    My Hood
Edit My Info
View Events
Read Tutorials
Training Modules
View Presentations
Download Tools
Scan News
Get Jobs
Message Forums
School Forums
Member Directory
   
CONTRIBUTE:
    Sign me up!
Post an Event
Submit Tutorials
Upload Tools
Link News
Post Jobs
   
   
Home >  Tutorials >  General Coding >  Microsoft Visual Studio.NET: Crystal Reports
Add to MyHood
   Microsoft Visual Studio.NET: Crystal Reports   [ printer friendly ]
Stats
  Rating: 4.33 out of 5 by 9 users
  Submitted: 10/30/02
Mujtaba Khambatti ()

 
Microsoft Visual Studio.NET: Crystal Reports

This is a brief article about VS.NET's new addition: Crystal Reports.

Benefits of Crystal Reports

Use the programming language of your choice and access the Crystal Report Designer from any project.
Crystal Reports for Visual Studio .NET provides two report viewers with which you can view your report in your application: use the Web Forms Viewer for Web applications and the Windows Forms Viewer for Windows applications.
Once you choose your development framework, Crystal Reports provides you with the report viewer appropriate to both your application and your development language. These report viewers are also customizable in that you can change the appearance and the available options of the toolbar.
Initialize properties of the Web Forms Viewer and the Windows Forms Viewer at design time. Or, set up your Web Forms Viewer or Windows Forms Viewer to interact with other controls at runtime. With runtime customization, users can view different reports, or change the format, data selection, or export options of an existing report.
The Report Object Model exposed by the Report Engine allows you to add code to the source file of the Windows Forms page to enable the Windows Forms Viewer control to interact with other controls in the same page.
For example, the Windows Forms control can interact with a button or combo box to provide users with export and report formatting options.

Designing a Report

In the Crystal Report Designer, you first select the data source that your report will reference. You can use more than one data source in a report.
Next, you choose the database tables you want to use in the report. Crystal Reports can automatically link the tables, or you can specify how you want the tables linked. Database tables are linked so records from one database match related records from another.
The Crystal Report Designer uses a drag-and-drop approach similar to Visual Studio .NET — you drag a report object onto the Designer (such as a database field or text object) and use the Property window or shortcut menu to format the object.
Some report objects that you can add to your report and format according to your needs include:

Database fields
Formula fields
Parameter fields
Group Name fields
Running Total fields
Summary fields
Charts
Subreports

The Crystal Report Designer is divided into report sections, such as section headers, footers, and details. You drag objects onto a report section.
The data that appears in the finished report is contingent upon your design choices. In particular, report data varies depending on the sections into which you choose to insert particular report objects. For example, if you insert a chart object in the Report Header section, the chart will appear only once at the beginning of the report and will summarize the data contained in the report. Alternatively, if a chart object is added to the Group Header section, a separate chart will appear at the beginning of each group of data and will summarize the data relating only to that group.

Using Crystal Reports in Projects you create

A report added to a Visual Basic or C# project is a "strongly-typed" report. A report source file, containing a report class specific to this report, is automatically created for it. This report class has ReportClass as its base class. For more information on the ReportClass class, please refer to the derived class ReportDocument .
The report source file also shows sections of the Crystal report. These sections should not be modified.
The report source file has the extension .cs for a Visual C# project, and .vb for a Visual Basic project. This file is normally hidden. You can click the Show All Files icon to list it (e.g., under CrystalReport1.rpt) in the Solution Explorer.

To add a new Crystal report to a project

In the Solution Explorer, right-click the project name, point to Add and select Add New Item from the shortcut menu. (Alternatively, highlight the project name in the Solution Explorer; from the Project menu in the Visual Studio Standard Toolbar, select Add New Item.)
In the Add New Item dialog box, select Crystal Report from the Templates pane.
Alternatively, expand the folder tree in the Categories pane, highlight Utility, and select Crystal Report from the Templates pane.
Enter a report name with an .rpt extension in the Name field. Or, accept the default report file name, CrystalReport1.rpt, if it exists.
Click Open to invoke the Crystal Report Designer that helps you create and design the new report.

To add an existing Crystal report to a project

In the Solution Explorer, right-click the project name and point to Add and select Add Existing Item from the shortcut menu.
In the Add Existing Item dialog box, select All Files under Files of type. Specify the location and name of the report you are adding.

Return to Browsing Tutorials

Email this Tutorial to a Friend

Rate this Content:  
low quality  1 2 3 4 5  high quality

Reader's Comments Post a Comment
 
Good job. I have been curious about crystal reports but never had any really good and small intro to it. 5*.
-- Sushant Bhatia, November 07, 2002
 
Good job.So, my brother today asked me: "ok, I know how to make the reports, but how do actually PRINT them?" like on paper, I guess. Any quick-and-dirty way?
-- Daniele Pagano, November 08, 2002
 
You can print an entire report from a .NET Web application to a printer by using the following three methods:

1. Export the report to a format that can be printed by a client's existing application.

2. Print the report on the server side using the "PrintToPrinter" method.

3. Print the report on the client side using the Internet Explorer browser

For detailed information on printing reports from a .NET web application, go to http://support.crystaldecisions.com/docs and search for:

Crnet_web_app_printing.pdf


-- Mujtaba Khambatti, November 08, 2002
 
Thanks!
-- Daniele Pagano, November 10, 2002
 
Now the big question has been answered in my mind! Thanks :)
-- Jan Bayer, December 10, 2002
 
I was not going to use Crystal Reports because I did not know what they were. Thanks for this.
-- Y M Marie, December 10, 2002
 
Copyright © 2001 DevHood® All Rights Reserved