How to draw a border around both the column header, footer and detail sections?

前端 未结 4 1250
无人共我
无人共我 2020-12-06 06:32

I have a requirement to have a border that will encapsulate all the details + the column header in a report made in JasperReports + iReport. But if I try to draw a rect or a

相关标签:
4条回答
  • 2020-12-06 06:32
    1. Click your jasper report.
    2. Go to basic Elements.
    3. choose rectangle.
    0 讨论(0)
  • 2020-12-06 06:34

    you can use the background-band on which you draw a rectangle for that purpose .

    0 讨论(0)
  • 2020-12-06 06:41

    To do this you can put frames into each of the bands, setting their size to fill the band completely. Then set the borders on the frames to replicate a border around all three bands, so the header has a border at the top, left and right; the footer has bottom, left and right; and the detail band has a border only on the left and right. See the example code below.

    <columnHeader>
        <band height="61" splitType="Stretch">
            <frame>
                <reportElement x="0" y="0" width="555" height="61"/>
                <box>
                    <topPen lineWidth="2.0" lineStyle="Solid"/>
                    <leftPen lineWidth="2.0" lineStyle="Solid"/>
                    <rightPen lineWidth="2.0" lineStyle="Solid"/>
                </box>
            </frame>
        </band>
    </columnHeader>
    <detail>
        <band height="125" splitType="Stretch">
            <frame>
                <reportElement x="0" y="0" width="555" height="125"/>
                <box>
                    <leftPen lineWidth="2.0" lineStyle="Solid"/>
                    <rightPen lineWidth="2.0" lineStyle="Solid"/>
                </box>
            </frame>
        </band>
    </detail>
    <columnFooter>
        <band height="45" splitType="Stretch">
            <frame>
                <reportElement x="0" y="0" width="555" height="45"/>
                <box>
                    <leftPen lineWidth="2.0" lineStyle="Solid"/>
                    <bottomPen lineWidth="2.0" lineStyle="Solid"/>
                    <rightPen lineWidth="2.0" lineStyle="Solid"/>
                </box>
            </frame>
        </band>
    </columnFooter>
    

    The result should look like this: Screenshot from iReport

    0 讨论(0)
  • 2020-12-06 06:43

    Using a background band with a Frame or Rectangle seems to work best, although, if the first and subsequent pages have different Header Elements, sizing the Frame/Rectangle can be a bit tricky.

    One way round this is to add a Frame/Rectangle on the any Title, Header and Footer bands, which is Opaque/White and sent to the Back. This will obscure the Background Image.

    This means that it will just be show through for the Detail Band, so the Header and Footer Frame may need a bottom/top border depending on what you want.

    (I found that the problem with using a Frame in the Detail band with just side borders doesn't quite work as sometime the repeated detail band does not fill each page, so gaps are left in the borders at the sides)

    0 讨论(0)
提交回复
热议问题