12

如何创建包含表格数据的报告?

我能够创建一个包含以下详细信息的报告。它将数据排列在类似表格的结构中。

<jasperReport>  
.
.
    <pageHeader>
        <band height="30">
            <staticText>
                <reportElement x="0" y="0" width="69" height="24" />
                <textElement verticalAlignment="Bottom" />
                <text><![CDATA[ID: ]]></text>
            </staticText>
            <staticText>
                <reportElement x="140" y="0" width="69" height="24" />
                <textElement verticalAlignment="Bottom" />
                <text><![CDATA[NAME: ]]></text>
            </staticText>
            <staticText>
                <reportElement x="280" y="0" width="69" height="24" />
                <textElement verticalAlignment="Bottom" />
                <text><![CDATA[AGE: ]]></text>
            </staticText>
        </band>
    </pageHeader>
    <detail>
        <band height="30">
            <textField>
                <reportElement x="0" y="0" width="69" height="24" />
                <textFieldExpression class="java.lang.String"><![CDATA[$F{id}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="140" y="0" width="69" height="24" />
                <textFieldExpression class="java.lang.String"><![CDATA[$F{name}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="280" y="0" width="69" height="24" />
                <textFieldExpression class="java.lang.String"><![CDATA[$F{age}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
</jasperReport>

但是行和列没有边框?我如何在 Jasperreport 4.5 中实现这一点?

谢谢

4

1 回答 1

19
  • 您可以在 GUI 设计器(例如iReport )的帮助下添加边框,也可以手动添加元素(编辑jrxml文件),如下例所示:
<textField>
    <reportElement x="29" y="17" width="100" height="20"/>
    <box>
        <topPen lineWidth="1.0"/>
        <leftPen lineWidth="1.0"/>
        <bottomPen lineWidth="1.0"/>
        <rightPen lineWidth="1.0"/>
    </box>
    <textElement/>
    <textFieldExpression><![CDATA[$F{field}]]></textFieldExpression>
</textField>
  • iReport中,您可以使用“填充和边框”上下文菜单。 iReport 上下文菜单

  • Jaspersoft Studio中,您可以借助属性对话框(选项卡Borders)设置边框。

在此处输入图像描述

于 2012-04-23T10:49:29.580 回答