最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

elements in band don't stretch correctly in jasper reports - Stack Overflow

programmeradmin1浏览0评论

column2 and column3 don't stretch as column1 though if column 2 and 3 are higher than column1, column 1 will stretch right to their height

that's the code of my jasper report which i use as subreport

<jasperReport xmlns=";
              xmlns:xsi=";
              xsi:schemaLocation=" .xsd"
              name="subReport" pageWidth="555" pageHeight="802" columnWidth="535" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="12345678-1234-1234-1234-123456789012">

    <style name="Default" isDefault="true" mode="Transparent" fontName="Arial" pdfFontName="Arial" pdfEncoding="Identity-H"/>
    <subDataset name="dataset1">
        <queryString>
            <![CDATA[]]>
        </queryString>
        <field name="name" class="java.lang.String">
            <fieldDescription><![CDATA[name]]></fieldDescription>
        </field>
        <field name="state" class="java.lang.String">
            <fieldDescription><![CDATA[state]]></fieldDescription>
        </field>
    </subDataset>
    <parameter name="pln" class="java.lang.String" isForPrompting="false"/>
    <field name="name" class="java.lang.String">
        <fieldDescription><![CDATA[name]]></fieldDescription>
    </field>
    <field name="orw" class="java.util.List"/>
    <columnHeader>
        <band height="20" isSplitAllowed="true" splitType="Stretch">
            <printWhenExpression><![CDATA[$V{PAGE_NUMBER}==1]]></printWhenExpression>
            <textField isStretchWithOverflow="true">
                <reportElement x="50" y="0" width="150" height="20" stretchType="RelativeToBandHeight"/>
                <box >
                    <topPen lineWidth="1.0"/>
                    <leftPen lineWidth="1.0"/>
                    <bottomPen lineWidth="1.0"/>
                    <rightPen lineWidth="1.0"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font isBold="true" isItalic="true" isUnderline="false"/>
                </textElement>
                <textFieldExpression><![CDATA["col1"]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement x="200" y="0" width="150" height="20" stretchType="RelativeToBandHeight"/>
                <box>
                    <topPen lineWidth="1.0"/>
                    <leftPen lineWidth="1.0"/>
                    <bottomPen lineWidth="1.0"/>
                    <rightPen lineWidth="1.0"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font isBold="true" isItalic="true" isUnderline="false"/>
                </textElement>
                <textFieldExpression><![CDATA["col2"]]></textFieldExpression>
            </textField>
            <textField isStretchWithOverflow="true">
                <reportElement x="350" y="0" width="150" height="20" stretchType="RelativeToBandHeight"/>
                <box>
                    <topPen lineWidth="1.0"/>
                    <leftPen lineWidth="1.0"/>
                    <bottomPen lineWidth="1.0"/>
                    <rightPen lineWidth="1.0"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font isBold="true" isItalic="true" isUnderline="false"/>
                </textElement>
                <textFieldExpression><![CDATA["col3"]]></textFieldExpression>
            </textField>
        </band>
    </columnHeader>
    <detail>
        <band height="20" splitType="Stretch">
            <printWhenExpression><![CDATA[!$F{orw}.isEmpty()]]></printWhenExpression>
            <textField isStretchWithOverflow="true">
                <reportElement stretchType="ElementGroupHeight" x="50" y="0" width="150" height="20"/>
                <box leftPadding="10">
                    <topPen lineWidth="1.0"/>
                    <leftPen lineWidth="1.0"/>
                    <bottomPen lineWidth="1.0"/>
                    <rightPen lineWidth="1.0"/>
                </box>
                <textElement textAlignment="Center" verticalAlignment="Middle"/>
                <textFieldExpression><![CDATA[$F{name}.equals($P{pln}) ? $F{name} : $P{pln} + "\n" + $F{name}]]></textFieldExpression>
            </textField>
            <componentElement>
                <reportElement x="200" y="0" width="300" height="20" stretchType="ElementGroupHeight"/>
                <jr:list xmlns:jr="; xsi:schemaLocation=" .xsd" printOrder="Vertical">
                    <datasetRun subDataset="dataset1">
                        <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{orw})]]></dataSourceExpression>
                    </datasetRun>
                    <jr:listContents height="20" width="300">
                            <textField isStretchWithOverflow="true">
                                <reportElement  x="0" y="0" width="150" height="20" stretchType="ElementGroupHeight"/>
                                <box leftPadding="10">
                                    <topPen lineWidth="1.0"/>
                                    <leftPen lineWidth="1.0"/>
                                    <bottomPen lineWidth="1.0"/>
                                    <rightPen lineWidth="1.0"/>
                                </box>
                                <textElement textAlignment="Center" verticalAlignment="Middle" />
                                <textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
                            </textField>
                            <textField isStretchWithOverflow="true">
                                <reportElement  x="150" y="0" width="150" height="20" stretchType="ElementGroupHeight"/>
                                <box leftPadding="10">
                                    <topPen lineWidth="1.0"/>
                                    <leftPen lineWidth="1.0"/>
                                    <bottomPen lineWidth="1.0"/>
                                    <rightPen lineWidth="1.0"/>
                                </box>
                                <textElement textAlignment="Center" verticalAlignment="Middle" />
                                <textFieldExpression><![CDATA[$F{state} == null ? "unkn : $F{state}]]></textFieldExpression>
                            </textField>
                    </jr:listContents>
                </jr:list>
            </componentElement>
        </band>
    </detail>
</jasperReport>

I've tried different ways to fix it but it seems like text element in bundle ignores list total height and can stretch above it, though if list height is more it gonna stretch.

I would be pleased if anyone could help me with my question

发布评论

评论列表(0)

  1. 暂无评论