Java Reference
In-Depth Information
Setting Text Style for Individual Report Elements
Report styles can be shared among several report elements. By setting attributes in
the <textElement> sub-element of <staticText> and <textField> , JasperReports
allows us to set some properties for individual report elements. These attributes are
outlined in the following table:
Valid Values
Determines the spacing
between lines of text. A value
of 1_1_2 indicates a line and
a half of space between lines
of text.
1_1_2 , Double , Single
Indicates the text direction by
rotating it 90 degrees in the
specified direction.
Left , None , Right
Indicates the horizontal
alignment of the text.
Center , Justified , Left ,
Indicates the vertical
alignment of the text.
Bottom , Middle , Top
Indicates whether the element
text is styled.
true , false
The following snippet of a JRXML template illustrates how to use these attributes:
<reportElement x="0" y="0" width="555" height="30"/>
<textElement lineSpacing="Double" textAlignment="center"
<![CDATA[This text is not really important.]]>
This snippet would generate text using double spacing, horizontally, and vertically
centered. The <textElement> element is a sub-element of both <staticText> and
<textField> .
Use Styles to Create More Maintainable Reports
It is usually faster to set the text properties using the
<textElement> element. However, doing it this way prevents
us from reusing the styles across several elements. Report styles
allow us to do this, and they provide much more control than
the attributes in <textElement> .
Search WWH ::

Custom Search