【问题标题】:How to draw a border around both the column header, footer and detail sections?如何在列标题、页脚和详细信息部分周围绘制边框?
【发布时间】:2011-08-25 15:40:02
【问题描述】:

我需要有一个边框来封装 JasperReports + iReport 中制作的报告中的所有详细信息 + 列标题。但是,如果我尝试在列标题、详细信息和列页脚中绘制一个矩形或一个框架,我会收到一个错误消息,指出元素位置无效。

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

还有其他选择吗?

谢谢。

【问题讨论】:

    标签: jasper-reports


    【解决方案1】:

    为此,您可以将框架放入每个带中,设置它们的大小以完全填充带。然后在框架上设置边框以复制所有三个带的边框,因此标题在顶部、左侧和右侧都有边框;页脚有底部、左侧和右侧;细节带只有左右边框。请参阅下面的示例代码。

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

    结果应如下所示:

    【讨论】:

    • 还应该使用isFloatColumnFooter,否则细节和列脚之间会有间隙。 &lt;jasperReport xmlns = ... isFloatColumnFooter="true" ..&gt;
    【解决方案2】:

    为此,您可以使用在其上绘制矩形的背景带。

    【讨论】:

      【解决方案3】:

      使用带有框架或矩形的背景带似乎效果最好,但如果第一页和后续页面具有不同的页眉元素,则调整框架/矩形的大小可能有点棘手。

      解决此问题的一种方法是在任何标题、页眉和页脚带上添加一个框架/矩形, 这是不透明/白色并发送到后面。这会使背景图像变得模糊。

      这意味着它只会显示在 Detail Band 中,因此页眉和页脚框架可能需要底部/顶部边框,具体取决于您的需要。

      (我发现在细节带中使用仅具有侧边框的框架的问题并不完全有效,因为有时重复的细节带不会填满每一页,因此两侧的边框会留下间隙)

      【讨论】:

        【解决方案4】:
        1. 点击您的 jasper 报告。
        2. 转到基本元素。
        3. 选择矩形。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2015-01-10
          • 1970-01-01
          • 1970-01-01
          • 2011-01-19
          • 2023-03-13
          • 1970-01-01
          • 1970-01-01
          相关资源
          最近更新 更多