Java Reference
In-Depth Information
<staticText>
<reportElement x="0" y="35" width="555" height="25"
style="childStyle"/>
<text>
<![CDATA[This text uses the style called "childStyle", this
style inherits all the properties of its parents, and
overrides only the size.]]>
</text>
</staticText>
</band>
</detail>
</jasperReport>
There are a few things to be noted about this example. Notice the
isDefault="true"
attribute of the
parentStyle
. By default, this attribute makes all report elements
use this style without having to explicitly declare it. Since the first
<staticText>
element does not indicate what style to use, it will use the style named
parentStyle
,
by default. What style report elements use is defined by the
style
attribute of
the
<reportElement>
, as can be seen in the second
<staticText>
element in the
preceding template.
After compiling, filling, and exporting the JRXML template, we should have a report
like the following:
The
<style>
element contains numerous attributes. Some of the most commonly
used are outlined in the following table. Refer to the JasperReports website at
http://jasperreports.sourceforge.net/reference/index2.html#style
for
the complete list.
Attribute
Description
Valid Values
forecolor
Indicates the text color.
Either a hexadecimal RGB
value preceded by the #
character, or one of the
following predefined values:
black
,
blue
,
cyan
,
darkGray
,
gray
,
green
,
lightGray
,
magenta
,
orange
,
pink
,
red
,
yellow
,
white