Reputation: 41
I am using ireport-4.5.0,jasper-reports-4.5.0.I am trying to add the border to the column header.While i am googling i found that we can get the border using rectangle.I have used the rectangle but i didn't get the border.Below is the code i am using.
<columnHeader>
<band height="39" splitType="Stretch">
<rectangle>
<reportElement x="131" y="0" width="424" height="39"/>
</rectangle>
<rectangle>
<reportElement x="0" y="1" width="131" height="38"/>
</rectangle>
<staticText>
<reportElement x="11" y="16" width="108" height="14"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Business Name]]></text>
</staticText>
<staticText>
<reportElement x="154" y="10" width="361" height="20"/>
<textElement textAlignment="Center">
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Sales Report]]></text>
</staticText>
</band>
</columnHeader>
Can any one point me in the correct direction where i am doing the mistake.
Thanks In Advance.
Upvotes: 0
Views: 1888
Reputation: 3548
Use two rectangle for every static text filed. Try this but i did only for center text:-
<columnHeader>
<band height="39" splitType="Stretch">
<rectangle>
<reportElement x="131" y="0" width="424" height="39" backcolor="#FF6666"/>
</rectangle>
<rectangle>
<reportElement x="134" y="3" width="419" height="31"/>
</rectangle>
<staticText>
<reportElement x="154" y="10" width="361" height="20"/>
<textElement textAlignment="Center">
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Sales Report]]></text>
</staticText>
</band>
</columnHeader>
Upvotes: 0
Reputation: 505
the problem is the rectangle would need to be a little bigger than the field. if you think of layers you text box is on top of the rectangle and this is why you can't see the rectangle. Using the borders works much better. Just right click on the object and go to "padding and borders"
<columnHeader>
<band height="20" splitType="Stretch">
<staticText>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Business Name]]></text>
</staticText>
<staticText>
<box>
<pen lineWidth="0.5"/>
<topPen lineWidth="0.5"/>
<leftPen lineWidth="0.5"/>
<bottomPen lineWidth="0.5"/>
<rightPen lineWidth="0.5"/>
</box>
<textElement textAlignment="Center">
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Sales Report]]></text>
</staticText>
</band>
</columnHeader>
Upvotes: 2