0

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.

skaithepalli
  • 41
  • 1
  • 5
  • 1
    You can look at [Adding table border in jasperreports](http://stackoverflow.com/q/10278067/876298) post – Alex K Jul 03 '13 at 14:13
  • Hi Alex,I don't want to use the Padding And Borders.I need to use Rectangle only.I have edited my original question. – skaithepalli Jul 04 '13 at 04:31
  • Bcoz i need to add the border to subreport also.I think we don't have the Padding And Borders for subreports.So i need to use rectangle only. – skaithepalli Jul 04 '13 at 06:29
  • Can you post the screenshot? – Alex K Jul 04 '13 at 07:20
  • your example work fine with PDF and XHTML but in standard HTML the rectangles are lost. Frames might be a way to get around the HTML problem but they would use the padding and borders as well. I am unclear on how you do not have Padding an borders. – Mike Noland Jul 05 '13 at 15:47

2 Answers2

2

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>
Mike Noland
  • 505
  • 3
  • 10
  • Hi Mnoland.I don't want to use the Padding And Borders.I need to use Rectangle Only.I have tried by giving the Rectangle size greater then the field.But still i am not getting the border.I have edited my original question.Can you plz look into it.Thank You – skaithepalli Jul 04 '13 at 04:33
0

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>
Sharad
  • 3,562
  • 6
  • 37
  • 59