web-dev-qa-db-ja.com

jasperreportsにテーブルの境界線を追加する

データのようなテーブルを使用してレポートを作成するにはどうすればよいですか?

以下の詳細でレポートを作成することができました。データをテーブルのような構造に配置します。

<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でこれを実現するにはどうすればよいですか?

ありがとう

12
Mark Estrada
  • GUIデザイナを使用して境界線を追加するか(たとえば、iReport)、box要素を手動で追加できます(編集jrxml file)このサンプルのように:
<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では、"Padding And Borders"コンテキストメニューを使用できます。 iReport context menu

  • Jaspersoft Studioでは、Propertiesダイアログ(タブBorders)を使用して境界線を設定できます。

enter image description here

17
Alex K