Chapter 4 Crystal Report
Chapter 4 Crystal Report
Crystal Report is designed to work with your database to help you analyze and
interpret important information.
Makes it easy to create simple reports, and it also has the comprehensive tools you
need to produce complex or specialized reports.
Crystal report can connect to any data source, including relational databases like
Oracle.
Flexible and customized report: You can quickly create highly formatted, pixel-perfect
reports using SAP Crystal Reports with high level design interface and efficient workflows.
Powerful report delivery options: You can deliver personalized reports to your business
end-users in their preferred language and format.
Data source connectivity: You can connect to information sources directly. Data sources
include: Native, ODBC, OLE DB, and JDBC connectivity to relational, OLAP, web services,
XML, enterprise data sources, and salesforce.com.
Expanded support for Excel: You can take full advantage of the Excel file format by
allowing more data to be exported to a single worksheet, without spanning multiple
worksheets.
Windows operating system compatibility: SAP Crystal Reports software 2013 is certified
compatible with Microsoft Windows 7.
1| Page
OBJECT ORIENTED PROGRAMMING
Chapter IV – Crystal Report
Mobile compatibility: You can also open interactive reports through your mobile devices.
SAP Crystal Reports, Adobe Flash and HTML 5 integration: It enables SAP Crystal
Reports developers to produce powerful "mash-ups" pulling data from various sources.
Competitors: SAP Crystal Reports competes with several products in Microsoft market like
SQL Server Reporting Services SSRS, XtraReports, ActiveReports, and List & Label.
The crystal reports installation wizard works with Microsoft Windows Installer to guide you
through the installation process. The Installation wizard automatically recognizes your
computer’s operating system and updates files as required.
❖ Installation Requirements
o PC with AMD or Intel-based processors, Dual Core CPU, 2 GB RAM
o Approximately 4GB available hard drive space (for English only, 8 GB for all
languages)
o Microsoft Windows 7 SP1, Windows 8, Windows Server 2008 SP2, Windows Server
2008 R2 SP1, Windows Server 2012
❖ Technical Specification
Hardware Requirements: Intel Pentium III or equivalent processor, minimum 512 MB RAM
recommended
Disk Space: 2 GB for default installation with English language, 4 GB for default
installation with all languages installed
2| Page
OBJECT ORIENTED PROGRAMMING
Chapter IV – Crystal Report
3. Click Next.
4. You need to accept the EULA (End User License Agreement) – click on I accept the
License agreement as shown on the image.
5. Click Next.
3| Page
OBJECT ORIENTED PROGRAMMING
Chapter IV – Crystal Report
6. Wait for the installation to finish and click Finish button.
4| Page
OBJECT ORIENTED PROGRAMMING
Chapter IV – Crystal Report
DESIGN TAB AREAS (SECTIONS)
1. Report Header
o This section is generally used for the report title and other information you want
to appear at the beginning of the report. It can also be used for charts and cross-
tabs that include data for the entire report.
2. Page Header
o This section is generally used for information that you want to appear at the top
of each page. This can include such things as chapter names, the name of the
document, and other similar information. This section can also be used to display
field titles above the fields on a report.
3. Details
o This section is used for the body of the report, and is printed once per record. The
bulk of the report data generally appears in this section.
4. Report Footer
o This section is used for information you want to appear only once at the end of
the report (such as grand totals) and for charts and cross-tabs that include data
for the entire report.
5. Page Footer
o This section usually contains the page number and any other information you
want to appear on the bottom of each page.
5| Page
OBJECT ORIENTED PROGRAMMING
Chapter IV – Crystal Report
LET’S DO IT!
For now, we will be discussing how to display data in a report in two (2) ways.
A. Using a DataSet
A set of data during run time wherein data are being stored in a data table and are
available when needed.
Just for example, you are using a datagridview to display data on your program and you
want those data to be displayed in your report; follow these steps:
3. Add DataSet on your project (click on Project menu > Add New Item or press
Ctrl+Shift+A), search for DataSet and click Add.
4. Add DataTable (from the dataset added, right click on the space on the DataSet and
click Add then choose DataTable)
6| Page
OBJECT ORIENTED PROGRAMMING
Chapter IV – Crystal Report
*DataTable serves as a new table for you to add the content of the DataGridView.
6. On your Project menu, click Add New Item then look for Crystal Report and click
Add
7. This will prompt you to choose what type of Report you want to create. Choose As a
Blank Report and click OK.
8. Design the report (add a Header, Logo, print date) – on the Report Header and Footer
9. Under Field Explorer, right click Database Fields and choose Database Expert
10. Click the + sign before the Project data
11. Click the + sign before the ADO.Net DataSets
12. Click the + sign before your .Dataset1 then choose DataTable1 and the > button.
13. Add the needed fields to the details tab of the report. – drag and drop into the Details
section.
7| Page
OBJECT ORIENTED PROGRAMMING
Chapter IV – Crystal Report
14. Add another Form and name it as frmPreview – Allows you to preview your report
before printing.
15. Change the WindowState property of your frmPreview to Maximized
16. On the toolbars, add crystal report viewer on frmPreview. Just drag and drop to
your frmPreview. (if Crystal Report Viewer is missing on the toolbox, please perform
steps A and B)
THESE STEPS SHOWS HOW TO INCLUDE CRYSTAL REPORT VIEWER ON YOUR
TOOLBAR
A. On project menu, click Properties
B. In the Compile tab, click Advanced Compile Options button, you need to set the
Target framework to .Net Framewrok 3.5 then click OK, then YES. –see image
8| Page
OBJECT ORIENTED PROGRAMMING
Chapter IV – Crystal Report
17. On your btnPrintPreview Button, type the following codes
18. Dim DT as New DataTable
19. With DT
20. .columns.Add(“---“)
21. .columns.Add(“---“)
22. .columns.Add(“---“)
23. End With
9| Page
OBJECT ORIENTED PROGRAMMING
Chapter IV – Crystal Report
B. Using Parameters
Setting parameters are easy as 1 2 3. These parameters display strings that are not
present on your datagridview for example a textbox. If you want to include some strings
that are displayed in a textbox or label, just set and use a parameter.
1. On your crystal report design from the previous discussion, right click on
Parameters Field and click New.
2. Type the name of a parameter without space and any special character.
Example: I want to include the complete or full name of the person who logged in to
the system as the prepared by. I will name the parameter as Preparedby and click
OK. If you want to add more parameter, repeat the step.
The name of the The Address of the The full name of the
company is company is person who logged
displayed in the displayed in the in to the system is
lblTitle lblAddress displayed in the
lblFullName
10 | P a g e
OBJECT ORIENTED PROGRAMMING
Chapter IV – Crystal Report
3. Add these codes between rptDoc.SetDataSource(DT) and
frmPreview.CrystalReportViewer1.ReportSource = rptDoc
UCase is used to
capitalize the
FullName and the
company name.
4. On your Crystal Report design, drag and drop your parameters into your design and
modify some properties such as size and font to make it good-looking.
PREVIEW:
11 | P a g e
OBJECT ORIENTED PROGRAMMING
Chapter IV – Crystal Report
12 24
13 25
14 26
15 27
16 28
17 29
18 30
19 Prepared by:
20 SYSTEM USER
21
22
23
CCSReport Page 2 of 3 CCSReport Page 3 of 3
PAGE 2 PAGE 3
12 | P a g e
OBJECT ORIENTED PROGRAMMING
Chapter IV – Crystal Report
HOW TO ADD DYNAMIC IMAGES TO A REPORT?
1. Insert an image in Section 1 (Report Header) – top left. – right click > Insert > Picture
5. Under Formatting Formulas > Report Header > Picture 1 > Graphic Location > Report Fields
- double click imglogo *refer to the next image.
13 | P a g e
OBJECT ORIENTED PROGRAMMING
Chapter IV – Crystal Report
✓
✓
✓
✓✓
✓
imglogo It is the
parameter added into
your crystal report to
hold the logo.
14 | P a g e
OBJECT ORIENTED PROGRAMMING
Chapter IV – Crystal Report
SAMPLE REPORT
15 | P a g e