jasper报告丢失部分数据

时间:2017-03-16 15:04:32

标签: jasper-reports

我正在使用jsapersoft studio 6.2.2.final生成pdf。

模板如下所示: enter image description here

在详细的乐队中,有一个框架包括$ F {info3}和$ F {desc1}。它们设置为带有溢出的拉伸。

元素$ F {desc1}的

,其数据来自数据库,如下所示:

String desc1 = "ABCD 123456789\n" 
               +"DEFGH CARD\n"
               +"MY NO.: T26111101M;T26110702M;T26120705M;T26121201M;T26092204M;T26092203M;T27021310M;T27030301M;\n"
               +"MY CARD" ;

在生成的pdf中,对于此元素,正确的结果应为:

ABCD 123456789 
DEFGH CARD
MY NO.: 
T26111101M;T26110702M;T26120705M;T26121201M;T26092204M;T26092203M;T27021310M;T270303
01M;
MY CARD

但生成的结果是:

ABCD 123456789  
DEFGH CARD 
MY NO.: 
T26111101M;T26110702M;T26120705M;T26121201M;T26092204M;T26092203M;T27021310M;T270303 
01M;

错过最后一行信息 MY CARD

但是,如果我将 \ n 添加到 MY CARD ,那就是:

String desc1 = "ABCD 123456789\n" 
               +"DEFGH CARD\n"
               +"MY NO.: T26111101M;T26110702M;T26120705M;T26121201M;T26092204M;T26092203M;T27021310M;T27030301M;\n"
               +"MY CARD\n" ;

最后一行信息我的卡可以在新行显示。

为什么?

或者,如果我删除了我的NO.:...n,那么我的CARD也可以用01M看到并放置;在同一行。

详情请参阅以下.rxml文件:

 <?xml version="1.0" encoding="UTF-8"?>
    <!-- Created with Jaspersoft Studio version 6.2.2.final using JasperReports Library version 6.2.2  -->
    <!-- 2017-03-16T15:02:36 -->
    <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="Blank_A4_2" pageWidth="595" pageHeight="842" columnWidth="575" leftMargin="10" rightMargin="10" topMargin="0" bottomMargin="10" uuid="0fde433a-fcca-431a-8090-de6eaa05c053">
        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
        <property name="com.jaspersoft.studio.unit." value="pixel"/>
        <parameter name="BACKGROUND_URL" class="java.lang.String"/>
        <queryString>
            <![CDATA[]]>
        </queryString>
        <field name="name1" class="java.lang.String"/>
        <field name="name2" class="java.lang.String"/>
        <field name="date1" class="java.lang.String"/>
        <field name="remark1" class="java.lang.String"/>
        <field name="alias3" class="java.lang.String"/>
        <field name="alias4" class="java.lang.String"/>
        <field name="info1" class="java.lang.String"/>
        <field name="no2" class="java.lang.String"/>
        <field name="desc1" class="java.lang.String"/>
        <field name="date2" class="java.lang.String"/>
        <field name="place3" class="java.lang.String"/>
        <field name="place4" class="java.lang.String"/>
        <field name="name3" class="java.lang.String"/>
        <field name="name4" class="java.lang.String"/>
        <field name="info3" class="java.lang.String"/>
        <field name="remark2" class="java.lang.String"/>
        <field name="alias5" class="java.lang.String"/>
        <background>
            <band height="822">
                <image>
                    <reportElement x="0" y="0" width="595" height="822" uuid="83a6fe1a-8ef2-4adb-9b0d-b3181f507ea4">
                        <printWhenExpression><![CDATA[$V{PAGE_NUMBER}.intValue() == 1]]></printWhenExpression>
                    </reportElement>
                    <imageExpression><![CDATA[$P{BACKGROUND_URL}]]></imageExpression>
                </image>
            </band>
        </background>
        <columnHeader>
            <band height="25">
                <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                <printWhenExpression><![CDATA[$V{PAGE_NUMBER}.intValue()>1]]></printWhenExpression>
                <frame>
                    <reportElement x="0" y="0" width="584" height="24" uuid="a40af4c1-9d1a-46dd-9fbb-1e18b3b8a24e"/>
                    <box>
                        <bottomPen lineWidth="1.0"/>
                    </box>
                    <staticText>
                        <reportElement x="0" y="12" width="190" height="12" uuid="1c89750d-552c-4ca6-9fff-f7b5c6827273">
                            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                        </reportElement>
                        <box>
                            <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                            <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                            <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                            <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        </box>
                        <textElement textAlignment="Center">
                            <font fontName="Arial" size="8"/>
                        </textElement>
                        <text><![CDATA[header2]]></text>
                    </staticText>
                    <staticText>
                        <reportElement x="190" y="12" width="150" height="12" uuid="2d1fb77e-1401-41d8-9014-3d829f38ba6a">
                            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                        </reportElement>
                        <box>
                            <topPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                            <leftPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                            <bottomPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                            <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
                        </box>
                        <textElement>
                            <font fontName="Arial" size="8"/>
                        </textElement>
                        <text><![CDATA[header3]]></text>
                    </staticText>
                    <staticText>
                        <reportElement x="422" y="12" width="60" height="12" uuid="d1782d41-3bcb-465d-9920-550ad7d49246">
                            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                        </reportElement>
                        <textElement>
                            <font fontName="Arial" size="8"/>
                        </textElement>
                        <text><![CDATA[header4]]></text>
                    </staticText>
                    <staticText>
                        <reportElement x="504" y="12" width="56" height="12" uuid="85925348-b121-4165-849f-5f9f245dabfd">
                            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                        </reportElement>
                        <textElement>
                            <font fontName="Arial" size="8"/>
                        </textElement>
                        <text><![CDATA[header5]]></text>
                    </staticText>
                </frame>
            </band>
        </columnHeader>
        <detail>
            <band height="400" splitType="Stretch">
                <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement x="24" y="34" width="274" height="68" uuid="e8b33602-087b-4fd6-b137-b9860e5b2e87"/>
                    <textElement>
                        <font fontName="Arial" size="8"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{alias3}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement x="24" y="113" width="274" height="58" uuid="afc09bed-11b5-4269-8cd4-c87283733d3b"/>
                    <textElement>
                        <font fontName="Arial" size="8"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{alias4}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement x="24" y="182" width="274" height="68" uuid="b0bde079-27d7-4add-a567-e1a5b9f64069"/>
                    <textElement>
                        <font fontName="Arial" size="8"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{info1}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement x="24" y="261" width="190" height="36" uuid="22603fa1-4318-44c8-b9f4-f4586b29e941"/>
                    <textElement>
                        <font fontName="Arial" size="8"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{name4}]]></textFieldExpression>
                </textField>
                <textField isBlankWhenNull="true">
                    <reportElement x="234" y="317" width="90" height="15" uuid="85212a8c-7509-499a-b4ec-76fde7d5aa6a"/>
                    <textElement verticalAlignment="Middle">
                        <font fontName="Arial" size="8"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{name3}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement x="24" y="332" width="511" height="14" uuid="09622c03-31f4-47ce-a0b2-68d40e7aab02"/>
                    <textElement>
                        <font fontName="Arial" size="8"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{remark2}]]></textFieldExpression>
                </textField>
                <frame>
                    <reportElement positionType="Float" x="24" y="347" width="543" height="45" uuid="d1ff5160-658d-4671-bf1c-89422a1e95f1"/>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement positionType="Float" x="0" y="0" width="159" height="45" uuid="646edbaf-8099-42c5-a428-471017ca231d">
                            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                        </reportElement>
                        <textElement>
                            <font fontName="Arial" size="8"/>
                        </textElement>
                        <textFieldExpression><![CDATA[$F{info3}]]></textFieldExpression>
                    </textField>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement positionType="Float" x="159" y="0" width="384" height="45" uuid="b9a10cac-3050-492f-8c07-2be97bef1443">
                            <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                        </reportElement>
                        <textElement>
                            <font fontName="Arial" size="8"/>
                        </textElement>
                        <textFieldExpression><![CDATA[$F{desc1}]]></textFieldExpression>
                    </textField>
                </frame>
            </band>
        </detail>
        <columnFooter>
            <band height="257">
                <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                <printWhenExpression><![CDATA[$V{PAGE_NUMBER}.intValue()==1]]></printWhenExpression>
                <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                    <reportElement x="180" y="17" width="226" height="12" uuid="edd9d794-d6db-4398-9262-d6ca229a1ab2">
                        <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                    </reportElement>
                    <textElement textAlignment="Left">
                        <font fontName="Arial" size="8" isBold="true"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$F{remark1}]]></textFieldExpression>
                </textField>
                <textField evaluationTime="Report">
                    <reportElement x="0" y="1" width="567" height="16" uuid="df777678-02bf-4fe1-ab16-7f78668282e8"/>
                    <textElement textAlignment="Center">
                        <font fontName="Arial" isBold="true"/>
                    </textElement>
                    <textFieldExpression><![CDATA[$V{PAGE_NUMBER}>1?"*******SEE ATTACHMENT*******":""]]></textFieldExpression>
                </textField>
                <frame>
                    <reportElement positionType="Float" x="24" y="31" width="549" height="36" uuid="b7263ccf-b108-4d38-a053-e60e9696111c"/>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="156" y="0" width="277" height="12" uuid="e188562d-5af9-464f-838a-b55ad69e9d0e"/>
                        <textElement textAlignment="Left">
                            <font fontName="Arial" size="8"/>
                        </textElement>
                        <textFieldExpression><![CDATA[$F{name1} + "/" + $F{name2}]]></textFieldExpression>
                    </textField>
                    <staticText>
                        <reportElement x="156" y="24" width="76" height="12" uuid="dec3acc7-cda2-4bec-9d53-56bbabfec173"/>
                        <textElement>
                            <font fontName="Arial" size="8"/>
                        </textElement>
                        <text><![CDATA[DATE:]]></text>
                    </staticText>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="233" y="24" width="84" height="12" uuid="8e57f858-162a-430a-8e55-a8b3855801da"/>
                        <textElement>
                            <font fontName="Arial" size="8"/>
                        </textElement>
                        <textFieldExpression><![CDATA[$F{date1}]]></textFieldExpression>
                    </textField>
                </frame>
                <frame>
                    <reportElement x="24" y="116" width="511" height="47" uuid="99d96936-4388-425d-ba78-ad4585040ba3"/>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="1" y="1" width="100" height="14" uuid="f005f85f-6757-45b7-8de0-cdff8cab93f7">
                            <property name="com.jaspersoft.studio.unit.x" value="pixel"/>
                            <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                            <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                        </reportElement>
                        <textElement>
                            <font fontName="Arial" size="8"/>
                        </textElement>
                        <textFieldExpression><![CDATA[$F{place4}]]></textFieldExpression>
                    </textField>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="135" y="0" width="100" height="14" uuid="87e23104-7d83-4acb-9a81-8f45ed59439f">
                            <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                        </reportElement>
                        <textElement>
                            <font fontName="Arial" size="8"/>
                        </textElement>
                        <textFieldExpression><![CDATA[$F{no2}]]></textFieldExpression>
                    </textField>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="272" y="1" width="100" height="14" uuid="a4081ee5-76a6-4a37-956d-411fd892d716">
                            <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                        </reportElement>
                        <textElement>
                            <font fontName="Arial" size="8"/>
                        </textElement>
                        <textFieldExpression><![CDATA[$F{place3}]]></textFieldExpression>
                    </textField>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="411" y="1" width="100" height="14" uuid="4008baf3-d936-40e6-8b86-10742247812a">
                            <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                        </reportElement>
                        <textElement>
                            <font fontName="Arial" size="8"/>
                        </textElement>
                        <textFieldExpression><![CDATA[$F{date2}]]></textFieldExpression>
                    </textField>
                    <textField isStretchWithOverflow="true" isBlankWhenNull="true">
                        <reportElement x="0" y="27" width="266" height="20" uuid="fd3e77fe-5351-4802-8d12-1750486f459b"/>
                        <textElement>
                            <font fontName="Arial" size="8"/>
                        </textElement>
                        <textFieldExpression><![CDATA[$F{alias5}]]></textFieldExpression>
                    </textField>
                </frame>
            </band>
        </columnFooter>
        <pageFooter>
            <band height="20" splitType="Stretch">
                <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                <textField>
                    <reportElement x="355" y="1" width="129" height="17" uuid="009c7eca-0ca8-4bd8-ab1a-7ad973e45065"/>
                    <textElement textAlignment="Right"/>
                    <textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER}]]></textFieldExpression>
                </textField>
                <textField evaluationTime="Report">
                    <reportElement x="484" y="1" width="100" height="18" uuid="f87b03b3-dcd3-43f6-9e97-55937c89b101"/>
                    <textElement textAlignment="Left"/>
                    <textFieldExpression><![CDATA[" of " + $V{PAGE_NUMBER}]]></textFieldExpression>
                </textField>
            </band>
        </pageFooter>
    </jasperReport>

1 个答案:

答案 0 :(得分:0)

为了我的价值,我找到了原因:

String desc1 = "ABCD 123456789\n" 
               +"DEFGH CARD\n"
               +"MY NO.: T26111101M;T26110702M;T26120705M;T26121201M;T26092204M;T26092203M;T27021310M;T27030301M;\n"
               +"MY CARD" ;

因为

MY NO.:T26111101M;T26110702M;T26120705M;T26121201M;T26092204M;T26092203M;T27021310M;T27030301M;\n

超出元素的宽度,它包含;所以这个问题发生了。

如果我删除;,则可以显示所有值。

也许这是一个错误,或者我错过了其他设置。