CS 112D Lecture Notes - Introduction to Crystal Reports
Introduction to Crystal Reports
- Crystal Reports is a collection of tools that are used to produce reports for viewing on the screen,
printing out, or viewing over the web.
- Here are a few pages on this topic from Visual Basic .NET, How to Program (2nd Edition), by
H. M. Deitel, P. J. Deitel, and T. R. Nieto. Copyright Prentice Hall 2002:
pages 1466-1467, pages 1468-1469 and page 1470.
It'll be easiest to read these pages as full-size images. In newer versions of Internet Explorer, you'll
have to hold your mouse over the image and click on the resize icon that appears in the lower-right
corner of the image.
- Here is the procedure to produce a basic report from a DataSet in VB 2003:
- Use the DataAdapter wizard and "Generate DataSet" feature to setup an instance of a typed DataSet
on your form.
- Right-click in Solution Explorer and select "Add New Item", then select "Crystal Report" from the
list of items that appears. From here you may use the Report Expert described in the reading mentioned
above. Go into the "Project Data" folder and "ADO.NET DataSets" to find the DataSet you generated.
Setup your report.
- From the Components tab of the Toolbox, add a "Report Document" to your form, based on the typed
report you just created.
- Add a "Crystal Report Viewer" to your form, which is found at the very end of the "Windows Forms"
tab of the Toolbox.
- Put the following code in your Form_Load procedure (assuming default names for all objects, and
assuming "Shippers" is the name of your DataTable):
OleDbDataAdapter1.Fill(DataSet11.Shippers)
crystalReport11.SetDataSource(DataSet11.Shippers)
CrystalReportViewer1.ReportSource = crystalReport11
- In VB 2005 the procedure is almost the same:
- Use the DataAdapter wizard and "Generate DataSet" feature to setup an instance of a typed DataSet
on your form.
- Right-click in Solution Explorer and select "Add New Item", then select "Crystal Report" from the
list of items that appears. From here you may use the Report Expert described in the reading mentioned
above. Go into the "Project Data" folder and "ADO.NET DataSets" to find the DataSet you generated.
Setup your report.
- From the "Crystal Reports" tab of the Toolbox, add a "Crystal Report Viewer" to your form. Go to
its "ReportSource" property, and select the report you created, under the heading, "Create a new
ReportDocument instance from a typed Report class". This should add a typed ReportDocument to your
form.
- Put the following code in your Form_Load procedure (assuming default names for all objects, and
assuming "Shippers" is the name of your DataTable):
OleDbDataAdapter1.Fill(DataSet11.Shippers)
crystalReport11.SetDataSource(DataSet11)
- Here is a self-extracting (run it to extract files) zip file
containing a project that uses Crystal Reports (downloaded from their web site)
- Crystal Reports Project Example done in class
Return to the main CS 112D page