我需要有一个staticText
浮动在另一个高度可变的元素下方。我正在从书中抽取样本JasperReports for Java Programmers
。它说有可能做到这一点。与我的示例不同的是,我在 中使用硬编码字符串textFieldExpression
,它们使用 $F{} 字段。
<textField isStretchWithOverflow="true" hyperlinkType="None">
<reportElement x="0" y="0" width="100" height="24"/>
<box>
<pen lineWidth="0.5" lineStyle="Solid"/>
</box>
<textElement/>
<textFieldExpression class="java.lang.String"><![CDATA["jjjjjjjjjjj oooooooooo uuuuuuuuuu aaaaaaaaaa xxxxxxxxx u ttttt"]]></textFieldExpression>
</textField>
<staticText>
<reportElement positionType="Float" x="0" y="25" width="500" height="30"/>
<box>
<pen lineWidth="0.5" lineStyle="Solid"/>
</box>
<textElement/>
<text><![CDATA[ This staticText element has a positionType of "Float" ppp ]]></text>
</staticText>
它说,当您使用y 时positionType="Float"
,将忽略 y 属性,因为staticText
位于textField
. 这似乎可行,但是……他们有可能在骂我吗?有textField
y=0 和 height=24。有staticText
y=25。巧合?如果我更改staticText
'sy,很明显它不会被忽略:元素定位在我告诉它的任何位置。没有浮动!!!书中引用:
As we can see, setting the positionType attribute of <reportElement> to Float made JasperReports ignore the y position of the <staticText> element, which was pushed down by the stretched <textField> element.
不,我们看不到它是如何被忽略的,因为 y=25 是我们预期的!positionType="Float"
完全有用吗staticText
?谢谢!