如何在列标题,页脚和细节部分周围绘制边框? [英] How to draw a border around both the column header, footer and detail sections?

查看:149
本文介绍了如何在列标题,页脚和细节部分周围绘制边框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要求有一个边框,它将封装JasperReports + iReport中生成的报告中的所有细节+列标题。但是,如果我尝试在列标题,详细信息和列页脚中绘制一个矩形或一个框架,我会收到错误消息,说明元素位置无效。

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 frame that goes in both the columns header, the details and column footer, I get an error saying that the element position is invalid.

我想一个选项是使用图像(就像没有CSS的好旧的HTML时间......)但它会是一个PITA,因为如果一个字段溢出或有人改变一个部分的高度或宽度,图像将不得不改变...

I guess one option would be to use images (just like the good old HTML times without CSS...) but it would be a PITA since if a field overflow or if someone change the height or the width of a section, the image will have to change...

还有其他选择吗?

谢谢。

推荐答案

为此,您可以将帧放入每个波段,设置它们的大小以完全填充波段。然后在帧上设置边框以复制所有三个波段周围的边框,因此标题在顶部,左侧和右侧有一个边框;页脚有底部,左侧和右侧;并且细节带仅在左侧和右侧具有边框。请参阅下面的示例代码。

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:

这篇关于如何在列标题,页脚和细节部分周围绘制边框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆