我在 jasper 报告中有一个表格,我需要该表格中某些单元格的内容垂直对齐。 我正在尝试使用 iReport 编辑报告。
在 iReport 中,我可以进入单元格的属性并看到垂直对齐设置为“中间”。此外,当我直接查看 XML 时(见下文),我可以看到textElement标记具有 VerticalAlignment="Middle" 属性。
据我所知,文本应该在其小框中垂直对齐,但它无法正确对齐。
我希望有在 jasper 报告中垂直对齐内容经验的人能够指出我做错了什么。 非常感谢。
<textField
isStretchWithOverflow="false"
isBlankWhenNull="true"
evaluationTime="Now"
hyperlinkType="None"
hyperlinkTarget="Self" >
<reportElement
x="227"
y="0"
width="31"
height="14"
key="textField-4"/>
<box>
<topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
<bottomPen lineWidth="0.0" lineColor="#000000"/>
<rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="Times New Roman" pdfFontName="Times-Roman" size="8"/>
</textElement>
<textFieldExpression class="java.lang.String"><![CDATA[$F{someVariableName}]]></textFieldExpression>
</textField>
Run Code Online (Sandbox Code Playgroud)
因此,需要明确的是,我的报告中的内容是这样的:
|--------|
| text |
| |
| |
|--------|
Run Code Online (Sandbox Code Playgroud)
我想要的是这样的:
|--------|
| |
| text |
| |
|--------|
Run Code Online (Sandbox Code Playgroud)
以下是我解决此问题的方法(iReport 3.7.6):
在“设计器”选项卡中:
正如您所看到的,这将允许您按照您想要的方式放置静态文本。
如果您只能在 XML 中进行更改,则更改在 XML 中的显示方式如下:
<box topPadding="4"/>
Run Code Online (Sandbox Code Playgroud)
带静态文本代码块的示例:
<staticText>
<reportElement positionType="Float" mode="Opaque" x="14" y="27" width="118" height="14" forecolor="#FFFFFF" backcolor="#909090"/>
<box topPadding="4"/>
<textElement textAlignment="Center" verticalAlignment="Middle" rotation="None" lineSpacing="Single" markup="none">
<font fontName="Arial" size="7" isBold="true" isUnderline="false" isStrikeThrough="false" isPdfEmbedded="false"/>
</textElement>
<text><![CDATA[SAMPLE TEXT SAMPLE TEXT]]></text>
</staticText>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
18162 次 |
| 最近记录: |