当文本大小更大时,Jasper报告表分组列会错误地扩展

时间:2019-02-21 11:19:47

标签: jasper-reports report grouping

我用过Jasper Table。在下面的图片中,我看到了3个用红色椭圆标记的问题。

有两个列组:一个在蓝色bg中,另一个在橙色bg中。我已经将它们相应地分组了。当蓝色textField中的文本大小增加时,它会按预期向下扩展,但是橙色textField没有在同一行中扩展,因为我在橙色textField下方出现了蓝色带。

棕色的textField也会按预期向下扩展,但是同一行中的其他textField不会以相同的大小扩展。

蓝色的subEntity的textField发生了同样的事情。当它向下扩展时,该行中的其他textField不会按预期向下扩展。

以下是我的碧玉报告:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.6.0.final using JasperReports Library version 6.6.0  -->
<jasperReport xmlns="http://jasperreports.sourceforge.net/jasperreports" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports http://jasperreports.sourceforge.net/xsd/jasperreport.xsd" name="comm_table_report" pageWidth="350" pageHeight="195" whenNoDataType="AllSectionsNoDetail" columnWidth="347" leftMargin="0" rightMargin="3" topMargin="0" bottomMargin="0" whenResourceMissingType="Empty" uuid="eefa2e50-7ee9-4f7d-9383-36857eac6169">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
    <style name="Table_TH" mode="Opaque" backcolor="#0088FF">
        <box>
            <pen lineWidth="0.5" lineColor="#FFFFFF"/>
            <topPen lineWidth="0.5" lineColor="#FFFFFF"/>
            <leftPen lineWidth="0.5" lineColor="#FFFFFF"/>
            <bottomPen lineWidth="0.5" lineColor="#FFFFFF"/>
            <rightPen lineWidth="0.5" lineColor="#FFFFFF"/>
        </box>
    </style>
    <style name="Table_CH" mode="Opaque" backcolor="#E6F3FF">
        <box>
            <pen lineWidth="0.5" lineColor="#FFFFFF"/>
            <topPen lineWidth="0.5" lineColor="#FFFFFF"/>
            <leftPen lineWidth="0.5" lineColor="#FFFFFF"/>
            <bottomPen lineWidth="0.5" lineColor="#FFFFFF"/>
            <rightPen lineWidth="0.5" lineColor="#FFFFFF"/>
        </box>
    </style>
    <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#FFFFFF"/>
            <topPen lineWidth="0.5" lineColor="#FFFFFF"/>
            <leftPen lineWidth="0.5" lineColor="#FFFFFF"/>
            <bottomPen lineWidth="0.5" lineColor="#FFFFFF"/>
            <rightPen lineWidth="0.5" lineColor="#FFFFFF"/>
        </box>
    </style>
    <subDataset name="Dataset1" uuid="82cf33f8-4b7d-4333-941c-a1a3666453a9"/>
    <summary>
        <band height="195" splitType="Stretch">
            <frame>
                <reportElement positionType="Float" stretchType="ContainerHeight" x="0" y="0" width="347" height="194" uuid="c05c6acf-401b-4332-b063-9d58279359f2"/>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement positionType="Float" x="0" y="0" width="347" height="20" uuid="902c0c36-3785-4355-ae8d-7ee738897a15"/>
                    <box padding="3"/>
                    <textElement>
                        <font isBold="true"/>
                    </textElement>
                    <textFieldExpression><![CDATA["rptTitle"]]></textFieldExpression>
                </textField>
                <componentElement>
                    <reportElement positionType="Float" stretchType="ElementGroupHeight" x="0" y="20" width="347" height="175" isPrintWhenDetailOverflows="true" uuid="53db5714-3d68-460a-820d-a583d08115f9">
                        <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.VerticalRowLayout"/>
                        <property name="com.jaspersoft.studio.table.style.table_header" value="Table_TH"/>
                        <property name="com.jaspersoft.studio.table.style.column_header" value="Table_CH"/>
                        <property name="com.jaspersoft.studio.table.style.detail" value="Table_TD"/>
                        <property name="net.sf.jasperreports.export.headertoolbar.table.name" value=""/>
                    </reportElement>
                    <jr:table xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
                        <datasetRun subDataset="Dataset1" uuid="a10a50fd-8c78-4456-96cb-1533bc84c9a8">
                            <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.JREmptyDataSource()]]></dataSourceExpression>
                        </datasetRun>
                        <jr:column width="59" uuid="9ef6214a-865e-4649-b749-4ff56a8f018e">
                            <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column1"/>
                            <jr:columnHeader style="Table_CH" height="20" rowSpan="1">
                                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                    <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="59" height="20" forecolor="#FFFFFF" backcolor="#800000" uuid="2e2075e7-926e-4c47-8683-a0060035c093"/>
                                    <box padding="3"/>
                                    <textElement textAlignment="Center" verticalAlignment="Middle">
                                        <font size="11" isBold="true" isItalic="false"/>
                                    </textElement>
                                    <textFieldExpression><![CDATA["dspEntityTitle"]]></textFieldExpression>
                                </textField>
                            </jr:columnHeader>
                            <jr:columnFooter style="Table_CH" height="20" rowSpan="1">
                                <staticText>
                                    <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="59" height="20" forecolor="#FFFFFF" backcolor="#0080C0" uuid="976bf7c9-661f-4465-9705-df05479cc51e"/>
                                    <textElement textAlignment="Center" verticalAlignment="Middle">
                                        <font size="11" isBold="true" isItalic="false"/>
                                    </textElement>
                                    <text><![CDATA[TOTAL]]></text>
                                </staticText>
                            </jr:columnFooter>
                            <jr:detailCell style="Table_TD" height="20">
                                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                    <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="59" height="20" forecolor="#FFFFFF" backcolor="#0080FF" uuid="762a0324-e8f3-4c84-91c7-43f3c3387596"/>
                                    <box padding="3"/>
                                    <textElement textAlignment="Center" verticalAlignment="Middle">
                                        <font size="11" isBold="true"/>
                                    </textElement>
                                    <textFieldExpression><![CDATA["subEntity"]]></textFieldExpression>
                                </textField>
                            </jr:detailCell>
                        </jr:column>
                        <jr:columnGroup width="144" uuid="e38411f9-23ea-48ce-bdbe-96b38793e26f">
                            <property name="com.jaspersoft.studio.components.table.model.column.name" value="Columns [3]"/>
                            <jr:tableHeader style="Table_TH" height="20">
                                <frame>
                                    <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="144" height="20" backcolor="#0080FF" uuid="deda20df-8ee2-4031-b89f-d3f98909a24e"/>
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="144" height="20" forecolor="#FFFFFF" backcolor="#0080FF" uuid="180a474c-8cfb-4e82-a88a-6c1d59eefbd7"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle">
                                            <font size="11" isBold="true" isItalic="true"/>
                                        </textElement>
                                        <textFieldExpression><![CDATA["This is a supposedly big title - A Big Title for Part A"]]></textFieldExpression>
                                    </textField>
                                </frame>
                            </jr:tableHeader>
                            <jr:column width="48" uuid="02aeca5b-016e-4130-b4e2-806ef336594d">
                                <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column2"/>
                                <jr:columnHeader style="Table_CH" height="20" rowSpan="1">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="48" height="20" forecolor="#FFFFFF" backcolor="#0080FF" uuid="1a5c475b-80cb-484f-9da3-fbe59a4f4f71"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle">
                                            <font isBold="true" isItalic="true"/>
                                        </textElement>
                                        <textFieldExpression><![CDATA["dspCol1A"]]></textFieldExpression>
                                    </textField>
                                </jr:columnHeader>
                                <jr:columnFooter style="Table_CH" height="20" rowSpan="1">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="48" height="20" forecolor="#FFFFFF" backcolor="#808000" uuid="3450d433-18ea-4aa3-8627-81606a34199d"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle">
                                            <font size="11" isBold="true"/>
                                        </textElement>
                                        <textFieldExpression><![CDATA["vTotalSumA"]]></textFieldExpression>
                                    </textField>
                                </jr:columnFooter>
                                <jr:detailCell style="Table_TD" height="20">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" x="0" y="0" width="48" height="20" uuid="216140a1-6803-4c40-9c2d-5643ef1d01c5"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                        <textFieldExpression><![CDATA["commonStatsATotal"]]></textFieldExpression>
                                    </textField>
                                </jr:detailCell>
                            </jr:column>
                            <jr:column width="48" uuid="0e7253ad-b1ea-4849-9f32-fec1225eacb6">
                                <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column3"/>
                                <jr:columnHeader style="Table_CH" height="20" rowSpan="1">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="48" height="20" forecolor="#FFFFFF" backcolor="#0080FF" uuid="985a61cc-8089-48da-ac7f-8d518f51ef54"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle">
                                            <font isBold="true" isItalic="true"/>
                                        </textElement>
                                        <textFieldExpression><![CDATA["dspCol2A"]]></textFieldExpression>
                                    </textField>
                                </jr:columnHeader>
                                <jr:columnFooter style="Table_CH" height="20" rowSpan="1">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="48" height="20" forecolor="#FFFFFF" backcolor="#808000" uuid="bb384bda-5865-4042-8896-681d6300bd2b"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle">
                                            <font size="11" isBold="true"/>
                                        </textElement>
                                        <textFieldExpression><![CDATA["vPendingSumA"]]></textFieldExpression>
                                    </textField>
                                </jr:columnFooter>
                                <jr:detailCell style="Table_TD" height="20">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" x="0" y="0" width="48" height="20" uuid="847ee423-a8a0-4387-8ea8-0c71c8bbd2c8"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                        <textFieldExpression><![CDATA["commonStatsAPending"]]></textFieldExpression>
                                    </textField>
                                </jr:detailCell>
                            </jr:column>
                            <jr:column width="48" uuid="0dc35f5c-fe2c-4472-8345-95201fc29c75">
                                <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column4"/>
                                <jr:columnHeader style="Table_CH" height="20" rowSpan="1">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="48" height="20" forecolor="#FFFFFF" backcolor="#0080FF" uuid="e94facd9-717e-4db7-a659-de01a886df55"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle">
                                            <font isBold="true" isItalic="true"/>
                                        </textElement>
                                        <textFieldExpression><![CDATA["dspCol3A"]]></textFieldExpression>
                                    </textField>
                                </jr:columnHeader>
                                <jr:columnFooter style="Table_CH" height="20" rowSpan="1">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="48" height="20" forecolor="#FFFFFF" backcolor="#808000" uuid="de000991-8bbd-43ef-ae3d-f82c264f393c"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle">
                                            <font size="11" isBold="true"/>
                                        </textElement>
                                        <textFieldExpression><![CDATA["vPercentageA"]]></textFieldExpression>
                                    </textField>
                                </jr:columnFooter>
                                <jr:detailCell style="Table_TD" height="20">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" x="0" y="0" width="48" height="20" uuid="b3edde52-4fd6-44c7-a6b3-015527401206"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                        <textFieldExpression><![CDATA["commonStatsACompletedPercentage"]]></textFieldExpression>
                                    </textField>
                                </jr:detailCell>
                            </jr:column>
                        </jr:columnGroup>
                        <jr:columnGroup width="144" uuid="7c545ad8-f566-4bb8-b1b7-92e7d2be6ba8">
                            <property name="com.jaspersoft.studio.components.table.model.column.name" value="Columns [3]"/>
                            <jr:tableHeader style="Table_TH" height="20">
                                <frame>
                                    <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="144" height="20" backcolor="#FF8000" uuid="0074d1ea-aced-44ce-b4f5-ef7ca85fa9c5"/>
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="144" height="20" forecolor="#FFFFFF" backcolor="#FF8000" uuid="c2147c38-1764-4896-8fe8-7e05e9ef60a7"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle">
                                            <font size="11" isBold="true" isItalic="true"/>
                                        </textElement>
                                        <textFieldExpression><![CDATA["Small title for Part B"]]></textFieldExpression>
                                    </textField>
                                </frame>
                            </jr:tableHeader>
                            <jr:column width="48" uuid="853e7ce9-d90e-44ff-824a-165e5e474e93">
                                <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column5"/>
                                <jr:columnHeader style="Table_CH" height="20" rowSpan="1">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="48" height="20" forecolor="#FFFFFF" backcolor="#FF8000" uuid="2fb46ba4-8c65-47bb-8e08-0a1683343ad6"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle">
                                            <font isBold="true" isItalic="true"/>
                                        </textElement>
                                        <textFieldExpression><![CDATA["dspCol1B"]]></textFieldExpression>
                                    </textField>
                                </jr:columnHeader>
                                <jr:columnFooter style="Table_CH" height="20" rowSpan="1">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="48" height="20" forecolor="#FFFFFF" backcolor="#808000" uuid="974093ed-c12c-47f4-912b-d39493d12e81"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle">
                                            <font size="11" isBold="true"/>
                                        </textElement>
                                        <textFieldExpression><![CDATA["vTotalSumB"]]></textFieldExpression>
                                    </textField>
                                </jr:columnFooter>
                                <jr:detailCell style="Table_TD" height="20">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" x="0" y="0" width="48" height="20" uuid="f63bf128-0227-4b8c-9353-9c75a0c334c7"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                        <textFieldExpression><![CDATA["commonStatsBTotal"]]></textFieldExpression>
                                    </textField>
                                </jr:detailCell>
                            </jr:column>
                            <jr:column width="48" uuid="c9fcb0fb-4532-446e-b817-add22e8831e1">
                                <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column6"/>
                                <jr:columnHeader style="Table_CH" height="20" rowSpan="1">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="48" height="20" forecolor="#FFFFFF" backcolor="#FF8000" uuid="982187a4-953c-41d1-b894-1c6a1ed9abcb"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle">
                                            <font isBold="true" isItalic="true"/>
                                        </textElement>
                                        <textFieldExpression><![CDATA["dspCol2B"]]></textFieldExpression>
                                    </textField>
                                </jr:columnHeader>
                                <jr:columnFooter style="Table_CH" height="20" rowSpan="1">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="48" height="20" forecolor="#FFFFFF" backcolor="#808000" uuid="9d52ad04-b8d1-45e3-a06e-7c2a97120739"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle">
                                            <font size="11" isBold="true"/>
                                        </textElement>
                                        <textFieldExpression><![CDATA["vPendingSumB"]]></textFieldExpression>
                                    </textField>
                                </jr:columnFooter>
                                <jr:detailCell style="Table_TD" height="20">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" x="0" y="0" width="48" height="20" uuid="560c8973-1e3c-415d-bc9b-11ff6cc98f09"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                        <textFieldExpression><![CDATA["commonStatsBPending"]]></textFieldExpression>
                                    </textField>
                                </jr:detailCell>
                            </jr:column>
                            <jr:column width="48" uuid="d914988e-ba76-40d4-bd05-7c575392fcc0">
                                <property name="com.jaspersoft.studio.components.table.model.column.name" value="Column7"/>
                                <jr:columnHeader style="Table_CH" height="20" rowSpan="1">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="48" height="20" forecolor="#FFFFFF" backcolor="#FF8000" uuid="989cbf92-33cb-4dfb-812b-953b6df6a403"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle">
                                            <font isBold="true" isItalic="true"/>
                                        </textElement>
                                        <textFieldExpression><![CDATA["dspCol3B"]]></textFieldExpression>
                                    </textField>
                                </jr:columnHeader>
                                <jr:columnFooter style="Table_CH" height="20" rowSpan="1">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" mode="Opaque" x="0" y="0" width="48" height="20" forecolor="#FFFFFF" backcolor="#808000" uuid="1a7f4716-709d-41d2-9da0-9af715ac1a72"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle">
                                            <font size="11" isBold="true"/>
                                        </textElement>
                                        <textFieldExpression><![CDATA["vPercentageB"]]></textFieldExpression>
                                    </textField>
                                </jr:columnFooter>
                                <jr:detailCell style="Table_TD" height="20">
                                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                                        <reportElement positionType="Float" stretchType="ElementGroupHeight" x="0" y="0" width="48" height="20" uuid="99c6a08b-b37e-43c4-a755-6a0fbfdd205c"/>
                                        <box padding="3"/>
                                        <textElement textAlignment="Center" verticalAlignment="Middle"/>
                                        <textFieldExpression><![CDATA["commonStatsBCompletedPercentage"]]></textFieldExpression>
                                    </textField>
                                </jr:detailCell>
                            </jr:column>
                        </jr:columnGroup>
                    </jr:table>
                </componentElement>
            </frame>
        </band>
    </summary>
</jasperReport>

以下是当前打印不正确的输出。问题区域以红色椭圆标记:

report with problem areas marked red

以下是我期望的输出:

Expected Output

我认为问题出在分组和元素高度上,但是不知何故我陷入了困境。也许有人可以指出我正确的方向。

让我知道我的疑问是否明确。预先感谢。

1 个答案:

答案 0 :(得分:0)

对于未在表中扩展的所有文本元素(小标题,dspCol,subEntity)或与此相关的所有元素,将stretchType="ElementGroupHeight"更改为stretchType="ContainerHeight"

stretchType="ElementGroupHeight"用于放置在<elementGroup>中的元素,您不使用它们。