0% found this document useful (0 votes)
19 views15 pages

Chapter 4 Crystal Report

Uploaded by

Warren Ligmayo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views15 pages

Chapter 4 Crystal Report

Uploaded by

Warren Ligmayo
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 15

OBJECT ORIENTED PROGRAMMING

Chapter IV – Crystal Report


CRYSTAL REPORT IN VISUAL STUDIO 2010

WHAT IS A 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.

WHAT CAN YOU DO WITH THE CRYSTAL REPORT?

• Create any report you can imagine


o It is designed to produce the report you want from virtually any data source. Built-in
report experts guide you step by step through building reports and completing
common reporting tasks.
• Extend reporting to the web
o The flexibility of Crystal Reports doesn’t end with creating reports – your reports can
be published in a variety of formats including MS Word, Excel, Email, and even over
the Web.
• Incorporate reports into applications
o Application and web developers can save time and meet their user's needs by
integrating the report processing power of crystal reports into their database
applications. Support for the most popular development languages makes it easy to
add reporting to any application.

BENEFITS OF CRYSTAL REPORT

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.

INSTALLING CRYSTAL REPORTS

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

Languages available: English, Finnish, French, German, Hungarian, Italian, Japanese,


Korean, Norwegian, Polish, Portuguese, Chinese simplified, Chinese traditional, Czech,
Danish, Dutch, Slovakian, Slovenian, Spanish, Swedish, Thai, Turkish, Romanian, Russian

❖ 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

❖ Steps on how to install Crystal Report on a computer


1. Double-click setup and click YES if asked.

2. Select the language then click OK.

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.

Sample report design:

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:

1. Design your application and connect it with your database.


2. Insert a button and name it as btnPrintPreview, change also the Text property to
Print Preview. – see image above below.

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

5. Add columns on your DataTable (ctrl+L or right click on


DataTable)
If you want to display all columns or field in the datagridview,
you need to add those fields in your datatable.

*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

Don’t forget to perform step number 16.

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

24. Below the End With, type the following codes


25. For Each DR As DataGridViewRow In Me.Datagridview1.Rows
26. DT.Rows.Add(DR.Cells(“---“).Value, DR.Cells(“---“).Value)
27. Next

28. On top of your code, type Imports CrystalDecisions

29. Type the following codes below the Next


30. Dim rptDoc As CrystalDecision.CrystalReports.Engine.ReportDocument
31. rptDoc=New CrystalReport1
32. rptDoc.SetDataSource(DT)
33. frmPreview.CrystalReportViewer1.ReportSource=rptDoc
34. frmPreview.Show

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.

We will be adding two more parameters as Company and Address.

Consider the data that are being shown in the frmMain

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

These are your


parameters

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

Report Header IFUGAO STATE UNIVERSITY


IFUGAO STATE UNIVERSITY COLLEGE OF COMPUTING SCIENCES

Page Header ID NAME COURSE AGE


COLLEGE OF COMPUTING SCIENCES 1
2
Details 3
ID NAME COURSE AGE 4
5
6
Report Footer 7
Prepared by: 8
SYSTEM USER 9
10
Page Footer 11
CCSReport Page N of N CCSReport Page 1 of 3

SAMPLE REPORT DESIGN PAGE 1

COLLEGE OF COMPUTING SCIENCES COLLEGE OF COMPUTING SCIENCES

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

For the meantime, add any image


(logo) from your computer.

This is just your basis on the size


of the image.

2. In the left pane, add a Parameter Field and name it as imglogo.

3. Right click the image and click Format Object

4. Select Picture tab and click

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




✓✓

This code will be


added after you
double click
imglogo

6. Add these codes to your pervious codes. rptDoc.SetParameterValue(“imglogo”,


txtLogoLocation.Text)

imglogo It is the
parameter added into
your crystal report to
hold the logo.

You should have a table or field in your


database to store the location of your
logo. During run time, the location is
retrieved and placed in the
txtLogoLocation.
Sample Text in the txtLogoLocation:
D:\CompanyLogo.jpeg

14 | P a g e
OBJECT ORIENTED PROGRAMMING
Chapter IV – Crystal Report
SAMPLE REPORT

15 | P a g e

You might also like