细节带中的自动高度矩形

时间:2014-07-16 10:12:32

标签: jasper-reports

我正在使用 iReport 。我想知道如何制作自动高度矩形?enter image description here

根据细节带的示例图像。有两个部分是右侧的数据部分,用于获取数据和显示。左侧部分是textarea数据,作为参数传递。 我想让两个矩形都相同。左侧数据高度可能大于右侧部分,反之亦然。所以我想让两个矩形高度始终相同。

为实现此目的,我使用以下代码。我不使用矩形但只使用一行

<columnHeader>
            <line>
            <reportElement x="0" y="28" width="555" height="1" uuid="9d2cb019-77f2-47a0-94f7-aa944b5c277e"/>
        </line>
    </band>
</columnHeader>

    <detail>
    <band height="13" splitType="Stretch">
        <textField>
            <reportElement x="472" y="0" width="50" height="13" uuid="4b51d986-b6f9-45e2-a151-e9d7f86007f3"/>
            <textElement textAlignment="Right" verticalAlignment="Middle">
                <font fontName="DejaVu Sans" size="8" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{packing}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="526" y="0" width="27" height="13" uuid="930cf91c-710a-40c4-a899-fde5ddfd7ce4"/>
            <textElement verticalAlignment="Middle">
                <font fontName="DejaVu Sans" size="8" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{sli_pack}]]></textFieldExpression>
        </textField>
        <line>
            <reportElement x="471" y="0" width="1" height="13" uuid="434d1954-3286-4539-a3d9-915f28364210"/>
        </line>
        <line>
            <reportElement x="555" y="-1" width="1" height="13" uuid="39dab81d-1bb3-41bd-8fff-9780b7f65672"/>
        </line>
        <line>
            <reportElement x="0" y="-1" width="1" height="13" uuid="8936db56-872f-434d-a39b-298ffdb99e57"/>
        </line>
    </band>
</detail>
<summary>
    <band height="1" splitType="Stretch">
        <line>
            <reportElement x="0" y="-1" width="555" height="1" uuid="ba7dbcc7-fd20-4ee9-b593-480737f9b88c"/>
        </line>
    </band>
</summary>

但这种方式的问题是矩形的角落没有正确打印。

我的问题是:

1)有没有更好的方法呢?

2)如何绘制完整细节带的边框?

3)如何用矩形做到这一点?

这是另一个尝试在细节带周围的矩形,但矩形重复到每一行。

<detail>
    <band height="13" splitType="Stretch">
        <rectangle>
            <reportElement stretchType="RelativeToTallestObject" x="1" y="0" width="552" height="13" uuid="80b946be-ac5f-495d-a507-fec3e22ea751"/>
        </rectangle>
        <textField>
            <reportElement x="465" y="0" width="50" height="13" uuid="4b51d986-b6f9-45e2-a151-e9d7f86007f3"/>
            <textElement textAlignment="Right" verticalAlignment="Middle">
                <font fontName="DejaVu Sans" size="8" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{packing}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="526" y="0" width="27" height="13" uuid="930cf91c-710a-40c4-a899-fde5ddfd7ce4"/>
            <textElement verticalAlignment="Middle">
                <font fontName="DejaVu Sans" size="8" pdfEncoding="Identity-H" isPdfEmbedded="true"/>
            </textElement>
            <textFieldExpression><![CDATA[$F{sli_pack}]]></textFieldExpression>
        </textField>
    </band>
</detail>

3 个答案:

答案 0 :(得分:0)

我认为你应该有一个矩形并在它们之间放一条线。使用line的属性,检查stretchWithOverflow为true。 Simillarly with rectangle。

答案 1 :(得分:0)

首先选择您的字段并设置以下属性(第三个最为重要):

  1. 位置类型:float
  2. Stretch类型:相对于最高的物体
  3. Stretch,其中溢出:true(已选中)

答案 2 :(得分:0)

您好,我想您可以在此链接的他们的文档中找到答案: https://community.jaspersoft.com/wiki/dynamically-set-table-row-height-data

总结一下,您应该启用这些选项。

enter image description here