Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding table border in jasperreports

How do you create a report with table like data?

I was able to create a report with details below. It arranges the data in a table-like structure.

<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>

But the rows and columns has no border? How do I achieve this in Jasperreport 4.5?

Thanks

like image 388
Mark Estrada Avatar asked Apr 23 '12 09:04

Mark Estrada


People also ask

How do you outline in Jaspersoft Studio?

Select "Windows" - "Display View" - "Other" - "Jaspersoft Studio". Select the view you want to add back. Select "Window" - "Show View" - "Other" - "General" - "Outline"

How do I add a table to Jasper report?

To create a table in a report, drag the Table element from the Elements palette inside any band of the report. The Table Wizard opens with a choice of creating a table from a new or existing dataset. If you choose to create an empty table, a new dataset is created and bound to the table.


1 Answers

  • You can add borders with help of GUI designer (iReport, for example) or you can add the box element manually (edit the jrxml file) like in this sample:
<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>
  • In iReport you can use "Padding And Borders" context menu. iReport context menu

  • In Jaspersoft Studio you can set borders with help of Properties dialog (tab Borders).

enter image description here

like image 163
Alex K Avatar answered Nov 12 '22 12:11

Alex K