public interface JRReport extends JRDefaultStyleProvider, JRPropertiesHolder, JRIdentifiable
The name of the report is specified using the name
attribute, and its inclusion
is mandatory. Spaces are not allowed in the report name - it must be a single word.
The default value for the language
property is java
, meaning that the Java language is
used for writing expressions, and that a report compiler capable of generating and
compiling a Java class on the fly is used for producing the bytecode needed for
expression evaluation at runtime.
Report compilers reference this property to see whether they can compile the supplied report template or whether a different report compiler should be used, depending on the actual scripting language.
Multicolumn report templates also have an associated column-filling order specified by
the printOrder
attribute.
By default, the reporting engine creates reports with one column on each page.
Vertical
- columns are filled from top to bottom and then left to right. This is the default print order.Horizontal
- columns are filled from left to right and then top to bottompageWidth
and pageHeight
. Like all the other JasperReports attributes that
represent element dimensions and position, these are specified in pixels. JasperReports
uses the default Java resolution of 72 dots per inch (DPI). This means that
pageWidth="595"
will be about 8.26 inches, which is roughly the width of an A4 sheet
of paper.
The default page size corresponds to an A4 sheet of paper:
pageWith="595" pageHeight="842"
orientation
attribute determines whether the documents use the
Portrait
or the Landscape
format.
This orientation
attribute is useful only at report-printing time to inform the printer
about the page orientation, and in some special exporters. The default page orientation
is Portrait
.
topMargin
,
leftMargin
, bottomMargin
, and rightMargin
.
The default margin for the top and bottom of the page is 20 pixels. The default margin for the right and left margins is 30 pixels.
columnCount
attribute. However, the reporting engine has to know how large a column
can be and how much space should be allowed between columns. Two attributes control
this: columnWidth
and columnSpacing
.
Also, when a report is compiled JasperReports checks whether the width of the overall columns and the space between them exceed the specified page width and page margins.
Since there is only one column by default, the default column spacing is 0 pixels and the default column width is 555 pixels (the default page width minus the default left and right margins).
The whenNoDataType
attribute lets users decide how the generated document should look
when there is no data in the data source supplied to it. Possible values of this attribute are as follows:
NoPages
- This is the default setting. The generated document will have no pages in it.
Viewers might throw an error when trying to load such documents.BlankPage
- the generated document will contain a single blank pageAllSectionsNoDetail
- All the report sections except the detail
section will appear in the generated document.NoData
- the generated document will contain only the NoData
sectionisTitleNewPage
isSummaryNewPage
When the summary section stretches to a new page, or starts on a new page altogether, it
is not accompanied by the page header and page footer. In order to force the page header
and page footer to reappear on summary trailing pages, set the
isSummaryWithPageHeaderAndFooter
to true; it is set to false by default.
isFloatColumnFooter
Boolean property lets users customize the behavior of the
column footer section. By default, this section is rendered at the bottom of the page, just
above the page footer. In certain cases, it is useful to render it higher on the page, just
below the last detail or group footer on that particular column. To do this, set the
isFloatColumnFooter
property to true.
scriptletClass
attribute is just a convenient way to specify the scriptlet class in case there is
only one scriptlet associated with the report.
This attribute is used by the engine only if no value is supplied for the built-in
REPORT_SCRIPTLET
parameter.
If neither the attribute nor the parameter
is used, and no other scriptlet is specified for the report using named scriptlet tags the
reporting engine uses a single
JRDefaultScriptlet
instance as the report
scriptlet.
$R{}
syntax.
There are two ways to associate the java.util.ResourceBundle
object with the
report template.
The first is a static association made by setting the resourceBundle
property of the
report template object to the base name of the target resource bundle.
A dynamic association can be made by supplying a java.util.ResourceBundle
object as the value for the
REPORT_RESOURCE_BUNDLE
parameter at report-filling time.
whenResourceMissingType
property allows users to choose the desired behavior
of the engine when it deals with missing locale-specific resources in the supplied
resource bundle. There are four different values that can be used to deal with missing
resources:
Null
- The null value is usedEmpty
- An empty string is usedKey
- The key is usedError
- An exception is raised in case a locale-specific resource is not found in the
supplied resource bundle for the given key and localeisIgnorePagination
property is set to true, the report-filling engine will
completely ignore page break-related settings inside the report template and generate the
document on a single, very long page. The value of this property can be overridden at
runtime using the optional, built-in
IS_IGNORE_PAGINATION
parameter.
formatFactoryClass
attribute lets users specify the name of the factory class
implementing the FormatFactory
interface,
which should be instantiated by the engine in order to produce java.text.DateFormat
and java.text.NumberFormat
objects to use for date and number formatting in the
current report.
This attribute specifying the factory class name is used only if no value is supplied for
the built-in REPORT_FORMAT_FACTORY
parameter.
If neither of the attribute nor the parameter is used, the engine will eventually instantiate
the DefaultFormatFactory
implementation
of the factory interface, which produces java.text.SimpleDateFormat
and
java.text.DecimalFormat
objects for date and number formatting.
This attribute or the built-in REPORT_FORMAT_FACTORY
parameter should be used only if the report relies on custom date and number formatters.
Some of the properties can be transferred onto the generated document and can be used by exporter to tailor their behavior.
The report templates can store application or user-defined properties in the form of
named values that can be archived by using any number or <property>
tags inside the
report template.
It is recommended that property names rely on some namespace policy, just as Java application packages do, to ensure that no naming conflict arises when several applications store information in the same report template.
Here is how a named value can be put inside the report template:
<property name="com.mycompany.report.author" value="John Smith"/> <property name="com.mycompany.report.description" value="Displays sales data"/>At runtime, this application-defined data can be retrieved from the report template using the public method
getPropertiesMap()
inherited from the JRPropertiesHolder
interface.
The name
attribute of a <style>
element is mandatory. It must be unique because it
references the corresponding report style throughout the report.
One can use isDefault="true"
for one of your report style declarations to mark the
default for elements that do not or cannot have another style specified.
Each report style definition can reference another style definition from which it will
inherit some or all of its properties. The style
attribute inside a <style>
element
specifies the name of the parent report style.
All report elements can reference a report style to inherit all or part of the style properties. A report style declaration groups all the style-related properties supported throughout the library, but an individual element inherits only those style properties that apply to it. The others will be ignored.
Sometimes users need to change a report element style at runtime based on certain conditions (for example, to alternate adjacent row colors in a report detail section). To achieve this goal, one can set some style properties to be enabled only if a specified condition is true. This is done using conditional styles.
The default style of a report can be accessed using the
getDefaultStyle()
method inherited from the
JRDefaultStyleProvider
interface.
JRParameter.IS_IGNORE_PAGINATION
,
JRParameter.REPORT_RESOURCE_BUNDLE
,
JRParameter.REPORT_SCRIPTLET
,
JRPropertiesMap
,
JRStyle
,
DefaultFormatFactory
,
FormatFactory
Modifier and Type | Field and Description |
---|---|
static String |
CONFIG_PROPERTY_WHEN_NO_DATA_TYPE
Property that specifies a default value for the
whenNoDataType attribute of report. |
static String |
LANGUAGE_GROOVY
A constant used to specify that the language used by expressions is Groovy.
|
static String |
LANGUAGE_JAVA
A constant used to specify that the language used by expressions is Java.
|
Modifier and Type | Method and Description |
---|---|
JRBand |
getBackground() |
int |
getBottomMargin() |
int |
getColumnCount()
Gets the number of columns on each page
|
RunDirectionEnum |
getColumnDirection()
Specifies whether columns will be filled from left to right or from right to left.
|
JRBand |
getColumnFooter() |
JRBand |
getColumnHeader() |
int |
getColumnSpacing()
Specifies the space between columns on the same page.
|
int |
getColumnWidth() |
JRDataset[] |
getDatasets()
Returns the datasets of this report.
|
JRSection |
getDetailSection() |
JRField[] |
getFields() |
String |
getFormatFactoryClass()
Gets the name of the class implementing the
FormatFactory
interface to use with this report. |
JRGroup[] |
getGroups() |
String[] |
getImports()
Gets an array of imports (needed if report expression require additional classes in order to compile).
|
String |
getLanguage()
Gets the report language.
|
JRBand |
getLastPageFooter() |
int |
getLeftMargin() |
JRDataset |
getMainDataset()
Returns the main report dataset.
|
String |
getName()
Gets the report name.
|
JRBand |
getNoData() |
OrientationEnum |
getOrientationValue()
Specifies whether document pages will be rendered in a portrait or landscape layout.
|
JRBand |
getPageFooter() |
JRBand |
getPageHeader() |
int |
getPageHeight() |
int |
getPageWidth() |
JRParameter[] |
getParameters() |
PrintOrderEnum |
getPrintOrderValue()
Specifies whether columns will be filled horizontally or vertically.
|
String |
getProperty(String name)
Gets a property value
|
DatasetPropertyExpression[] |
getPropertyExpressions()
Returns the list of dynamic/expression-based properties for this report.
|
String[] |
getPropertyNames()
Gets an array of report properties names.
|
JRQuery |
getQuery() |
String |
getResourceBundle()
Gets the base name of the report associated resource bundle.
|
int |
getRightMargin() |
String |
getScriptletClass() |
JRScriptlet[] |
getScriptlets() |
SectionTypeEnum |
getSectionType()
Specifies whether report sections are made of bands or of parts.
|
JRSortField[] |
getSortFields() |
JRStyle[] |
getStyles()
Gets an array of report styles.
|
JRBand |
getSummary() |
JRReportTemplate[] |
getTemplates()
Returns the list of report templates.
|
JRBand |
getTitle() |
int |
getTopMargin() |
JRVariable[] |
getVariables() |
WhenNoDataTypeEnum |
getWhenNoDataTypeValue()
Specifies the report behavior in case of empty datasources.
|
WhenResourceMissingTypeEnum |
getWhenResourceMissingTypeValue()
Returns the resource missing handling type.
|
boolean |
isFloatColumnFooter()
Specifies if the column footer section will be printed at the bottom of the column or if it
will immediately follow the last detail or group footer printed on the current column.
|
boolean |
isIgnorePagination()
Decides whether to use pagination when filling the report.
|
boolean |
isSummaryNewPage()
Specifies if the summary section will be printed on a separate last page.
|
boolean |
isSummaryWithPageHeaderAndFooter()
Specifies if the summary section will be accompanied by the page header and footer.
|
boolean |
isTitleNewPage()
Specifies if the title section will be printed on a separate initial page.
|
void |
removeProperty(String name) |
void |
setProperty(String name,
String value) |
void |
setWhenNoDataType(WhenNoDataTypeEnum whenNoDataType)
Sets the report behavior in case of empty datasources.
|
void |
setWhenResourceMissingType(WhenResourceMissingTypeEnum whenResourceMissingType)
Sets the resource missing handling type.
|
getDefaultStyle, getStyleResolver
getParentProperties, getPropertiesMap, hasProperties
getUUID
static final String CONFIG_PROPERTY_WHEN_NO_DATA_TYPE
whenNoDataType
attribute of report.static final String LANGUAGE_JAVA
static final String LANGUAGE_GROOVY
String getName()
String getLanguage()
int getColumnCount()
PrintOrderEnum getPrintOrderValue()
PrintOrderEnum
RunDirectionEnum getColumnDirection()
RunDirectionEnum
int getPageWidth()
int getPageHeight()
OrientationEnum getOrientationValue()
OrientationEnum
WhenNoDataTypeEnum getWhenNoDataTypeValue()
void setWhenNoDataType(WhenNoDataTypeEnum whenNoDataType)
SectionTypeEnum getSectionType()
SectionTypeEnum
int getColumnWidth()
int getColumnSpacing()
int getLeftMargin()
int getRightMargin()
int getTopMargin()
int getBottomMargin()
boolean isTitleNewPage()
boolean isSummaryNewPage()
boolean isSummaryWithPageHeaderAndFooter()
boolean isFloatColumnFooter()
String getScriptletClass()
String getFormatFactoryClass()
FormatFactory
interface to use with this report.String getResourceBundle()
String[] getPropertyNames()
String getProperty(String name)
name
- the property namevoid removeProperty(String name)
DatasetPropertyExpression[] getPropertyExpressions()
String[] getImports()
JRStyle[] getStyles()
JRScriptlet[] getScriptlets()
JRParameter[] getParameters()
JRQuery getQuery()
JRField[] getFields()
JRSortField[] getSortFields()
JRVariable[] getVariables()
JRGroup[] getGroups()
JRBand getBackground()
JRBand getTitle()
JRBand getPageHeader()
JRBand getColumnHeader()
JRSection getDetailSection()
JRBand getColumnFooter()
JRBand getPageFooter()
JRBand getLastPageFooter()
JRBand getSummary()
JRBand getNoData()
WhenResourceMissingTypeEnum getWhenResourceMissingTypeValue()
void setWhenResourceMissingType(WhenResourceMissingTypeEnum whenResourceMissingType)
whenResourceMissingType
- the resource missing handling typeJRDataset getMainDataset()
The main report dataset consists of all parameters, fields, variables and groups of the report.
JRDataset[] getDatasets()
boolean isIgnorePagination()
If set to true
the report will be generated on one long page.
The design attribute can be overridden at fill time by the IS_IGNORE_PAGINATION
parameter.
JRReportTemplate[] getTemplates()
template
.
Templates include styles which can be used in the report.
The order in which the templates are included in the report is important:
null
if noneJRTemplate
,
JRParameter.REPORT_TEMPLATES
Copyright © 2023 Cloud Software Group, Inc.. All rights reserved.