Java Reference
In-Depth Information
Again, the code to fill and export the report is similar to what we have seen before.
Therefore, we chose not to display it. The generated report should look like this:
The FixRelativeToTop value of the positionType attribute of <reportElement>
forces the element to stay in the same position regardless of whether any other
element stretches. Hence, we ended up with the two elements overlapping each
other, which is probably not what we want.
It would be nice if the <staticText> element would be pushed down, if the
<textField> element stretches. We can accomplish this by setting positionType
to Float .
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN"
"http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport name="FloatDemo" >
<field name="lots_of_data" class="java.lang.String"/>
<detail>
<band height="55">
<textField isStretchWithOverflow="true">
<reportElement x="0" y="0" width="100" height="24"/>
<box border="Thin"/>
<textFieldExpression class="java.lang.String">
<![CDATA[$F{lots_of_data}]]>
</textFieldExpression>
</textField>
<staticText>
<reportElement width="500" y="25" x="0" height="30"
positionType="Float"/>
<box border="Thin"/>
<text>
<![CDATA[This staticText element has a positionType of
"Float"]]>
</text>
</staticText>
</band>
</detail>
</jasperReport>
 
Search WWH ::




Custom Search