0% found this document useful (0 votes)
124 views74 pages

Course Jasper PPT

This document provides an overview and instructions for using JasperReports, an open source reporting tool. It discusses report design, database connections, parameters, fields, fonts, variables, sections, groups, styles, and creating subreports. The key sections covered include an introduction to reports and templates, the report lifecycle, designing reports using tags and elements, compiling and exporting reports, and incorporating subreports. The goal is to explain the main concepts and components for building reports with JasperReports.

Uploaded by

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

Course Jasper PPT

This document provides an overview and instructions for using JasperReports, an open source reporting tool. It discusses report design, database connections, parameters, fields, fonts, variables, sections, groups, styles, and creating subreports. The key sections covered include an introduction to reports and templates, the report lifecycle, designing reports using tags and elements, compiling and exporting reports, and incorporating subreports. The goal is to explain the main concepts and components for building reports with JasperReports.

Uploaded by

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

Designer for Jasper Report

5.6.0
Agenda
 INTRODUCTION
 LIFE CYCLE
 CREATING AND USING DATABASE JDBC CONNECTIONS
 DESIGN
 COMPILING REPORT DESIGN
 EXPORTING REPORTS
 REPORTS PARAMETERS
 REPORT FIELDS
 REPORT FONTS
 REPORT VARIABLES
 REPORT SECTIONS
 REPORT GROUPS
 REPORT STYLES
 CREATE SUBREPORTS
INTRODUCTION
 What is a Report?
Open source reporting software
 Report Template
 A4
 LandScape
 Letter
 Letter LandScape
 Report Sections
 Features of JasperReports

1) It has a flexible report layout.


2) It can accept data from the multiple data sources.
3) It can generate sub-reports.
4) Results exporting: There are a wide range of formats,
which your report can be exported to, such as: HTML,
Text, PDF, MS Excel, RTF, ODT, Comma-separated
values, XML, or image.
 Jasper Managers Classes
LIFE CYCLE
CREATING AND USING DATABASE JDBC CONNECTIONS

 A JDBC connection
To edit the connection dataBase, click File -> New ->
DataAdapter
 Step 1
 Step 2
 Step 3
 Step 4 “JDBC Drivers List”
 Step 5
 add the ojdbc6.jar file
 The Dataset
To create a dataset, right-click on the report root node
in the outline view and choose Create Dataset
 Step 1
 Step 2
 Add Query
 Choice column
DESIGN

 The JRXML templates (or JRXML files) in


JasperReport are standard XML files, having an
extension of .jrxml. All the JRXML files contain tag
<jasperReport>, as root element. This in turn contains
many sub-elements (all of these are optional).
 Creating a JRXML Report Template
<queryString>
<field name>
<fieldDescription>
<staticText>
<textFieldExpression>
<band>
COMPILING REPORT DESIGN

 We have generated the JasperReport template


(JRXML file) in the previous chapter. This file cannot
be used directly to generate reports. It has to be
compiled to JasperReport' native binary format,
called Jasper file.
EXPORTING REPORTS

 Exporting means transforming the JasperPrint object


(.jrprint file) into different format.
 The JasperExportManager provides methods to
export a report into PDF, HTML, and XML only.
 This code generates the following three files:
sample_report.pdf
sample_report.html
sample_report.xls
REPORTS PARAMETERS

 Parameter Declaration
<parameter name="exampleParameter" class="java.lang.String" />
The Name Attribute : <parameter>
The Class Attribute : $P{} java.lang.String.
 Built-in Parameters
REPORT_PARAMETERS_MAP
REPORT_CONNECTION
REPORT_DATA_SOURCE
REPORT_MAX_COUNT
REPORT_SCRIPTLET
REPORT_LOCALE
REPORT_RESOURCE_BUNDLE
REPORT_TIME_ZONE
REPORT_VIRTUALIZER
REPORT_CLASS_LOADER
IS_IGNORE_PAGINATION
REPORT FIELDS

 Field Declaration
<field name="FieldName" class="java.lang.String"/>
The Name Attribute : <field>
The Class Attribute : $F{}
Field Description : <fieldDesciption>
<fieldDescription><![CDATA[FieldName]]></fieldDescription>
 Elements
 Properties field
 Sort Fields <sortField>
At the times when data sorting is required and the data
source implementation doesn't support it
 Example
<sortField name="country" order="Descending"/>
REPORT FONTS

 A report contains text elements.


 using the <font> tag available in the <textElement>
tag. A report can define a number of fonts.
 Do not use <reportFont/> elements declared within
the document itself. Use the <style/> element instead
 Font Types
 Logical Fonts: Five font types, These are - Serif,
SansSerif, Monospaced, Dialog, and DialogInput
 Physical Fonts: These fonts are
the actual font :TrueType or PostScript Type.
the physical font Arial, Time, Helvetica, Courier,
or any number of other fonts, including international
fonts.
 Font Attributes
REPORT VARIABLES

 Report variables can perform various calculations


based on the corresponding expressions values such
as count, sum, average, lowest, highest, variance, etc.
The Name Attribute : </variable>
The Class Attribute : $V{}
Calculation : Average, Count, First, Highest, Lowest,
Nothing, StandardDeviation, Sum, System , Variance
 Built-In Report Variables
PAGE_NUMBER
COLUMN_NUMBER
REPORT_COUNT
PAGE_COUNT
COLUMN_COUNT
GroupName_COUNT
 Calculation
 Nothing: No calculations are performed on the variable.
 Average: The variable value is the average of every non-
null value of the variable expression. Valid for numeric
variables only.
 Count: The variable value is the count of non-null
instances of the variable expression.
 First: The variable value is the value of the first instance
of the variable expression. Subsequent values are
ignored.
 Highest: The variable value is the highest value for the
variable expression.
 Lowest: The variable value is the lowest value for the
variable expression in the report.
 Sum: The variable value is the sum of all non-null
values returned by the report expression.
 use the report inspector.
 Properties
 By dragging the field C inside the summary band
  Running the report
  The Tool Page
REPORT SECTIONS
 Main Sections
<title></title>
<pageheader></pageheader>
<columnheader></columnheader>
<groupheader></groupheader>
<detail></detail>
<groupfooter></groupfooter>
<columnfooter></columnfooter>
<pagefooter></pagefooter>
<summary></summary>
<nodata></nodata>
<background></background>
 Section Elements
 Section Attributes
 Height
Height of the section specifies the height in pixels for
that particular section and is very important in the
overall report design.
 Print When Expression
A Boolean expression that determines whether the
section should be printed or not.
REPORT GROUPS

 Groups in JasperReports help to organize data on


report in a logical manner. A report group represents
a sequence of consecutive records in the data source
 A report group is defined by the <group> element.
 Create new group
 The window to
create a new
group appears:
  Returning to the
creation of the group
 Deleting :
Deleting the Band, Deleting the Group
 A report group has three elements:
 Group expression:
This indicates the data that must change to start a new
data group.
 Group header section:
Helps place label at the beginning of the grouped data.
 Group footer section:
Helps place label at the end of the grouped data.
 Group Sections
<groupFooter> ,<groupHeader>
REPORT STYLES

 <style>
 This element is a collection of style settings declared
at the report level.
 Styles can extend other styles, and add to, or override
properties of the parent style as well.
 Style Properties
 Conditional Styles
A style should be applied only when certain condition is
met (for example, to alternate adjacent row colors in a
report detail section).
 The style is used only if the condition evaluates to
true.
 A conditional style has two elements:
 a Boolean condition expression
 a style
 Example
<style name="style" mode="Opaque" forecolor="#000000"
backcolor="#EDF0EF" fontName="Arial">
<conditionalStyle>
<conditionExpression>
<![CDATA[new Boolean($V{REPORT_COUNT}.intValue() % 2 == 0)]]>
</conditionExpression>
<style mode="Transparent" forecolor="#000000"/>
</conditionalStyle>
</style>
CREATE SUBREPORTS

 This feature allows incorporating a report within


another report, that is, one report can be a subreport
of another.
 Subreports help us keep report designs simple.
 We can create many simple reports and encapsulate
them into a master report.
 Subreports are compiled and filled just like normal
reports.
 SubReport Element
A <subreport> element is used when introducing
subreports into master reports.
 <reportElement>
 <parametersMapExpression>
This is used to pass a map containing report parameters
to the subreport. The map is usually obtained from a
parameter in the master report, or by using the built-in
REPORTS_PARAMETERS_MAP parameter to pass the
parent report's parameters to the subreport.
 <subreportParameter>
This element is used to pass parameters to the
subreport. It has an attribute name, which is
mandatory.
<subreportExpression>
<![CDATA["subReport.jasper"]]>
</subreportExpression>
 <connectionExpression>
This is used to pass a java.sql.Connection to the
subreport. It is used only when the subreport template
needs a database connection during report filling phase.
<connectionExpression>
<![CDATA[$P{REPORT_CONNECTION}]]>
</connectionExpression>
 <dataSourceExpression>
This is used to pass a datasource to the subreport. This
datasource is usually obtained from a parameter in the
master report or by using the built-in
REPORT_DATA_SOURCE parameter to pass the parent
report's datasource to the subreport.
 <returnValue>
This is used to assign the value of one of the subreport's
variables to one of the master report's variables.
 subreportVariable
This attribute specifies the name of the subreport
variable whose value is to be returned.
 toVariable
This attribute specifies the name of the parent report
variable whose value is to be copied/incremented with
the value from the subreport.
 Steps for create subReport
 Add report path
 Or Create a new report
Any Question ?

You might also like