Professional Documents
Culture Documents
Crystal Report 8.5 For Visual - 89028
Crystal Report 8.5 For Visual - 89028
By Roshni
Any Software Application designed to work with a database to analyze and interpret information
will need some kind of a report. There are tools, which help the programmer to create Reports
easily.
The Visual Studio.NET Integrated Development Environment comes with a reporting tool,
Crystal Reports 8.5 for .NET. Crystal Reports has been a powerful windows reporting tool for a
while now. So Microsoft chose that as the integrated reporting tool for .NET. Crystal Reports
can be hosted in both Web and Windows forms or can be published as a Report Web Service
on a Web server. It provides developers with data visualization and analysis capabilities through
seamless integration.
Crystal Reports can use different kinds of data sources and can be used to create different
types of reports like charts; cross-tab reports which use formulas, sub-reporting and conditional
formatting to provide easier understanding of data for the user.
Another advantage of using Crystal reports is that you dont have to install any additional
software to develop your reports and you dont need to distribute the report designer with your
report to the client makes the programmers life easier.
Run time customization is possible using the web or windows forms viewer. Which means users
can view different reports, change the format, data selection, or export options of an existing
report as the viewer control can interact with other controls in the same page. For Ex. By
clicking a button user can sort a report based on some a selected criteria.
The Crystal Report viewer control behaves differently in Windows forms and Web forms
1
Select Crystal report from the list of icons and name the report and click Open
2
Add a Data source for report
If you dont see the Field Explorer window on the screen. Select View-Other windows-
Document Outline from the Menu bar
Select a data source (you can select any existing dataset in your project or a stored procedure
or a table etc.) You will need to provide the login information for the database
3
You select the required Stored Procedure or table or dataset and add to the report
Select the fields to be shown in the report and put them in the proper sections of the report
Report Header
4
Page header
Detail
Page footer
Report footer.
Database fields
Formula fields
Parameter fields
Group Name fields
Running Total fields
Summary fields
Depending upon your requirements you place objects in the corresponding sections. You can
insert text boxes and special fields like date/time. Also you can insert unbound fields, which can
be connected (bound) to database during runtime
Set grouping, totaling and sorting if needed. Depending on the requirements you may have to
use formulas and sub reports also.
For inserting fields or grouping, sorting etc. you right click on the report and select the action
you want.
5
Formatting the report
You can set the font style and put images also. To format any object you right click on in and
select the format option.
2. Interacting with Visual Studio.NET
To view the report in VS.NET you need to do the following steps.
Add a CrystalReportViewer control to the form and customize the properties
The VS.NET tool bar has the CrystalReportViewer control. Drag and drop it in the form where
you need to view the report. ( if you dont want to show the report to the user you dont have to
use a viewer control.).
There is a tool bar in the viewer which has buttons for navigation, refresh etc. you can view or
hide them using the property window at design time.
Set the report source of the CRV. There are three ways to do this:
To set the Report Source property of a CrystalViewer control by report name:
Select CRV1.
To set the Report Source property of a CrystalViewer control by report document object:
6
Assign ReportDocument1 as the report source of CRV1
To set the Report Source property of a CrystalViewer control by local report object:
When the report to be displayed is created under the same project you can directly create an
object of that report and set it as the report source
When you use a tables or stored procedures as the data source of the report you will have to
pass the logon information to the report object in the code. The Code for that is as showed here.
The variable 'rep' is an object of the Crystal report to be displayed
Also when the report is made based on the parameter input from the user the inputs are passed
to the report as parameters for the selection formula or Stored proc behind the report
ChecksCRV.ReportSource = rep;
ParameterFields crParameterFields = new ParameterFields();
ParameterField crParameterField = new ParameterField();
ParameterDiscreteValue crParameterDiscreteValue = new
ParameterDiscreteValue();
crParameterFields = ChecksCRV.ParameterFieldInfo;
crParameterField = crParameterFields[0];
crParameterDiscreteValue.Value = Param1
crParameterField.CurrentValues.Add(crParameterDiscreteValue);
ChecksCRV.ParameterFieldInfo = crParameterFields;
ChecksCRV.ReportSource = rep;
paramDiscreteValue.Value = paramValue;
paramValues.Add (paramDiscreteValue);
rep.DataDefinition.ParameterFields["@param1"].ApplyCurrentValues(AddDi
screteValue(param1));
7
These are the basic steps the developer has to follow in order to show a report in a .NET
application.
http://msdn.microsoft.com/library/?url=/library/en-us/crystlmn/html/crconcrystalreports.asp?frame=true
http://www.crystaldecisions.com/products/dev_zone/net_walkthroughs.asp
http://dotnet247.com/247reference/msgs/g/ngfx-crystal.aspx
http://support.crystaldecisions.com/library/kbase.asp
http://support.crystaldecisions.com/forums/