2017-09-26 61 views
0

使用JasperReports打印某些PDF报表时出现问题。这些报告基本上是多年来向特定客户所做的所有销售的细目。JRXML子报表 - 消除底部的重复标题

我有一个主报告和子报告。

我从数据库中获取信息,使用Java进行转换,并以PDF格式打印报告。问题是,在某些罕见的情况下,一些标题重复出现在每个页面的底部:

enter image description here

在图像我需要删除圈子里的一部分。 我附上我的报告的代码如下。 MasterReport

> <?xml version="1.0" encoding="UTF-8"?> 
    <!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0 --> 
    <!-- 2017-09-26T12:38: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="scriptlet" pageWidth="1089" pageHeight="842" columnWidth="900" leftMargin="30" rightMargin="30" topMargin="30" bottomMargin="30" isFloatColumnFooter="true" whenResourceMissingType="Empty" uuid="fc422c67-db33-4432-b0fe-9c5b6cbdc01c"> 
     <property name="com.jasperassistant.designer.Grid" value="false"/> 
     <property name="com.jasperassistant.designer.SnapToGrid" value="false"/> 
     <property name="com.jasperassistant.designer.GridWidth" value="10"/> 
     <property name="com.jasperassistant.designer.GridHeight" value="10"/> 
     <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/> 
     <property name="com.jaspersoft.studio.unit." value="pixel"/> 
     <property name="net.sf.jasperreports.print.create.bookmarks" value="false"/> 
     <property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/> 
     <property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/> 
     <property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/> 
     <property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/> 
     <property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/> 
     <property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/> 
     <property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/> 
     <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/> 
     <parameter name="reportName" class="java.lang.String"/> 
     <parameter name="runDate" class="java.util.Date"/> 
     <parameter name="month" class="java.lang.String"/> 
     <parameter name="year" class="java.lang.Integer"/> 
     <parameter name="stations" class="java.lang.String"/> 
     <parameter name="contractType" class="java.lang.String"/> 
     <parameter name="cash" class="java.lang.String"/> 
     <parameter name="subReportParameter" class="java.lang.String"/> 
     <parameter name="innerSubReportParameter" class="java.lang.String"/> 
     <queryString> 
      <![CDATA[]]> 
     </queryString> 
     <field name="pageHeader" class="java.lang.String"> 
      <fieldDescription><![CDATA[pageHeader]]></fieldDescription> 
     </field> 
     <field name="pageHeaderTotal" class="java.lang.String"> 
      <fieldDescription><![CDATA[pageHeader]]></fieldDescription> 
     </field> 
     <field name="monthlyAmortizationReport" class="java.util.List"> 
      <fieldDescription><![CDATA[monthlyAmortizationReport]]></fieldDescription> 
     </field> 
     <field name="monthlyAmortizationReportTotal" class="java.util.List"> 
      <fieldDescription><![CDATA[monthlyAmortizationReportTotal]]></fieldDescription> 
     </field> 
     <group name="Group1"> 
      <groupHeader> 
       <band height="605"> 
        <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
        <frame borderSplitType="DrawBorders"> 
         <reportElement stretchType="RelativeToTallestObject" x="0" y="2" width="1030" height="70" uuid="0e09fd68-d674-4ffe-8026-27560a2f6fb8"/> 
         <box> 
          <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> 
          <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> 
          <bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> 
          <rightPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> 
         </box> 
         <staticText> 
          <reportElement x="35" y="21" width="100" height="15" uuid="091d6e12-3c88-4711-9278-c2990a483faa"> 
           <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
          </reportElement> 
          <box leftPadding="5"/> 
          <textElement textAlignment="Left" verticalAlignment="Middle"> 
           <font fontName="SansSerif" isBold="false"/> 
          </textElement> 
          <text><![CDATA[Station(s) Selected:]]></text> 
         </staticText> 
         <textField isStretchWithOverflow="true" pattern="MM/dd/yyyy" isBlankWhenNull="true"> 
          <reportElement x="135" y="21" width="210" height="15" uuid="6e396536-4be3-4b2b-b938-14088da8e46e"/> 
          <box leftPadding="5"/> 
          <textElement textAlignment="Left" verticalAlignment="Middle"> 
           <font fontName="SansSerif" isBold="false"/> 
          </textElement> 
          <textFieldExpression><![CDATA[$P{stations}]]></textFieldExpression> 
         </textField> 
        </frame> 
        <staticText> 
         <reportElement positionType="Float" x="47" y="123" width="240" height="15" uuid="8007ea73-d590-42b2-a7e3-e12e0958fd92"> 
          <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
         </reportElement> 
         <box leftPadding="5"/> 
         <textElement textAlignment="Left" verticalAlignment="Middle"> 
          <font fontName="SansSerif" isBold="false"/> 
         </textElement> 
         <text><![CDATA[Prepared By: ____________________________]]></text> 
        </staticText> 
        <staticText> 
         <reportElement positionType="Float" x="47" y="178" width="240" height="15" uuid="9d1717cd-fe4d-4ca3-87b0-ba035b59c801"> 
          <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
         </reportElement> 
         <box leftPadding="5"/> 
         <textElement textAlignment="Left" verticalAlignment="Middle"> 
          <font fontName="SansSerif" isBold="false"/> 
         </textElement> 
         <text><![CDATA[Reviewed By: ____________________________]]></text> 
        </staticText> 
        <staticText> 
         <reportElement positionType="Float" x="690" y="123" width="180" height="15" uuid="0d0d7a65-73ef-48b5-b66d-0bf87d3f6f3a"> 
          <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
         </reportElement> 
         <box leftPadding="5"/> 
         <textElement textAlignment="Left" verticalAlignment="Middle"> 
          <font fontName="SansSerif" isBold="false"/> 
         </textElement> 
         <text><![CDATA[Date: ________________________]]></text> 
        </staticText> 
        <staticText> 
         <reportElement positionType="Float" x="690" y="178" width="180" height="15" uuid="dfbfed6d-0058-474b-be0a-b0f35998e4bb"> 
          <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
          <property name="com.jaspersoft.studio.unit.x" value="pixel"/> 
         </reportElement> 
         <box leftPadding="5"/> 
         <textElement textAlignment="Left" verticalAlignment="Middle"> 
          <font fontName="SansSerif" isBold="false"/> 
         </textElement> 
         <text><![CDATA[Date: ________________________]]></text> 
        </staticText> 
        <break> 
         <reportElement positionType="FixRelativeToBottom" x="0" y="600" width="550" height="1" isPrintWhenDetailOverflows="true" uuid="cab606e6-99cd-454a-8749-2d5461d4f9a1"/> 
        </break> 
       </band> 
      </groupHeader> 
     </group> 
     <group name="pageHeader" isStartNewPage="true"> 
      <groupExpression><![CDATA[$F{pageHeader}]]></groupExpression> 
      <groupHeader> 
       <band height="1"> 
        <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/> 
        <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
        <subreport> 
         <reportElement x="0" y="0" width="1029" height="1" isRemoveLineWhenBlank="true" backcolor="#99CCFF" uuid="ec8271ee-6fb9-4c88-b730-b8031517400f"> 
          <property name="com.jaspersoft.studio.unit.width" value="pixel"/> 
          <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
         </reportElement> 
         <subreportParameter name="pageHeader"> 
          <subreportParameterExpression><![CDATA[$F{pageHeader}]]></subreportParameterExpression> 
         </subreportParameter> 
         <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource 
       ($F{monthlyAmortizationReport})]]></dataSourceExpression> 
         <subreportExpression><![CDATA[$P{subReportParameter}]]></subreportExpression> 
        </subreport> 
       </band> 
       <band height="1"> 
        <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
        <subreport> 
         <reportElement positionType="Float" x="0" y="0" width="1029" height="1" isRemoveLineWhenBlank="true" backcolor="#99CCFF" uuid="ec8271ee-6fb9-4c88-b730-b8031517400f"> 
          <property name="com.jaspersoft.studio.unit.width" value="pixel"/> 
          <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
         </reportElement> 
         <subreportParameter name="pageHeader"> 
          <subreportParameterExpression><![CDATA[$F{pageHeader}]]></subreportParameterExpression> 
         </subreportParameter> 
         <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource 
       ($F{monthlyAmortizationReportTotal})]]></dataSourceExpression> 
         <subreportExpression><![CDATA[$P{innerSubReportParameter}]]></subreportExpression> 
        </subreport> 
       </band> 
      </groupHeader> 
     </group> 
     <title> 
      <band height="162" splitType="Stretch"> 
       <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
       <staticText> 
        <reportElement x="35" y="0" width="70" height="15" uuid="d85beb8a-5178-43a7-8b24-5608250f088c"> 
         <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
        </reportElement> 
        <box leftPadding="5"/> 
        <textElement textAlignment="Left" verticalAlignment="Middle"> 
         <font fontName="SansSerif" isBold="false"/> 
        </textElement> 
        <text><![CDATA[Report Name:]]></text> 
       </staticText> 
       <textField isBlankWhenNull="true"> 
        <reportElement x="105" y="0" width="552" height="15" uuid="3e8eb96b-1b5e-4f34-b1ec-f5770049d23e"> 
         <property name="com.jaspersoft.studio.unit.width" value="pixel"/> 
        </reportElement> 
        <box leftPadding="5"/> 
        <textElement textAlignment="Left" verticalAlignment="Middle"> 
         <font fontName="SansSerif" isBold="false" isUnderline="false"/> 
        </textElement> 
        <textFieldExpression><![CDATA[$P{reportName}]]></textFieldExpression> 
       </textField> 
       <staticText> 
        <reportElement x="690" y="0" width="60" height="15" uuid="d85beb8a-5178-43a7-8b24-5608250f088c"> 
         <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
         <property name="com.jaspersoft.studio.unit.y" value="pixel"/> 
         <property name="com.jaspersoft.studio.unit.x" value="pixel"/> 
        </reportElement> 
        <box leftPadding="5"/> 
        <textElement textAlignment="Left" verticalAlignment="Middle"> 
         <font fontName="SansSerif" isBold="false"/> 
        </textElement> 
        <text><![CDATA[Run Date:]]></text> 
       </staticText> 
       <textField pattern="MM/dd/yyyy" isBlankWhenNull="true"> 
        <reportElement x="750" y="0" width="170" height="15" uuid="3e8eb96b-1b5e-4f34-b1ec-f5770049d23e"/> 
        <box leftPadding="5"/> 
        <textElement textAlignment="Left" verticalAlignment="Middle"> 
         <font fontName="SansSerif" isBold="false"/> 
        </textElement> 
        <textFieldExpression><![CDATA[$P{runDate}]]></textFieldExpression> 
       </textField> 
       <frame> 
        <reportElement x="0" y="50" width="1029" height="70" uuid="6df8b9cc-b364-433c-b589-cacf4f0a679b"> 
         <property name="com.jaspersoft.studio.unit.width" value="pixel"/> 
        </reportElement> 
        <box> 
         <topPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> 
         <leftPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> 
         <bottomPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> 
         <rightPen lineWidth="0.5" lineStyle="Solid" lineColor="#000000"/> 
        </box> 
        <textField isBlankWhenNull="true"> 
         <reportElement x="80" y="15" width="200" height="15" uuid="3e8eb96b-1b5e-4f34-b1ec-f5770049d23e"> 
          <property name="com.jaspersoft.studio.unit.x" value="pixel"/> 
         </reportElement> 
         <box leftPadding="5"/> 
         <textElement textAlignment="Left" verticalAlignment="Middle"> 
          <font fontName="SansSerif" isBold="false"/> 
         </textElement> 
         <textFieldExpression><![CDATA[$P{month}]]></textFieldExpression> 
        </textField> 
        <staticText> 
         <reportElement x="35" y="45" width="45" height="15" uuid="d85beb8a-5178-43a7-8b24-5608250f088c"> 
          <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
          <property name="com.jaspersoft.studio.unit.width" value="pixel"/> 
         </reportElement> 
         <box leftPadding="5"/> 
         <textElement textAlignment="Left" verticalAlignment="Middle"> 
          <font fontName="SansSerif" isBold="false"/> 
         </textElement> 
         <text><![CDATA[Year: ]]></text> 
        </staticText> 
        <textField isBlankWhenNull="true"> 
         <reportElement x="80" y="45" width="200" height="15" uuid="3e8eb96b-1b5e-4f34-b1ec-f5770049d23e"> 
          <property name="com.jaspersoft.studio.unit.y" value="pixel"/> 
         </reportElement> 
         <box leftPadding="5"/> 
         <textElement textAlignment="Left" verticalAlignment="Middle"> 
          <font fontName="SansSerif" isBold="false"/> 
         </textElement> 
         <textFieldExpression><![CDATA[$P{year}]]></textFieldExpression> 
        </textField> 
        <staticText> 
         <reportElement x="35" y="15" width="45" height="15" uuid="617febe3-cdac-4613-8986-b9dbd31a072d"> 
          <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
          <property name="com.jaspersoft.studio.unit.x" value="pixel"/> 
          <property name="com.jaspersoft.studio.unit.width" value="pixel"/> 
         </reportElement> 
         <box leftPadding="5"/> 
         <textElement textAlignment="Left" verticalAlignment="Middle"> 
          <font fontName="SansSerif" isBold="false"/> 
         </textElement> 
         <text><![CDATA[Month:]]></text> 
        </staticText> 
       </frame> 
      </band> 
     </title> 
     <pageFooter> 
      <band height="15"> 
       <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
       <textField isStretchWithOverflow="true"> 
        <reportElement x="0" y="0" width="385" height="15" uuid="3e8eb96b-1b5e-4f34-b1ec-f5770049d23e"> 
         <property name="com.jaspersoft.studio.unit.y" value="pixel"/> 
        </reportElement> 
        <box leftPadding="5"/> 
        <textElement textAlignment="Left" verticalAlignment="Middle"> 
         <font fontName="SansSerif" isBold="false" isUnderline="false"/> 
        </textElement> 
        <textFieldExpression><![CDATA[$P{reportName}]]></textFieldExpression> 
       </textField> 
       <textField evaluationTime="Page"> 
        <reportElement positionType="Float" x="386" y="0" width="150" height="15" uuid="e727b263-ae6c-4742-b102-64f0bc117b31"> 
         <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
         <property name="com.jaspersoft.studio.unit.width" value="pixel"/> 
        </reportElement> 
        <textElement textAlignment="Right" verticalAlignment="Middle"/> 
        <textFieldExpression><![CDATA["Page " + $V{PAGE_NUMBER} + " o"]]></textFieldExpression> 
       </textField> 
       <textField evaluationTime="Report"> 
        <reportElement positionType="Float" x="536" y="0" width="171" height="15" uuid="e727b263-ae6c-4742-b102-64f0bc117b31"> 
         <property name="com.jaspersoft.studio.unit.height" value="pixel"/> 
         <property name="com.jaspersoft.studio.unit.x" value="pixel"/> 
         <property name="com.jaspersoft.studio.unit.width" value="pixel"/> 
        </reportElement> 
        <textElement textAlignment="Left" verticalAlignment="Middle"/> 
        <textFieldExpression><![CDATA["f " + $V{PAGE_NUMBER}]]></textFieldExpression> 
       </textField> 
       <textField pattern="MM/dd/yyyy hh:mm:ss a" isBlankWhenNull="true"> 
        <reportElement x="708" y="0" width="320" height="15" uuid="3e8eb96b-1b5e-4f34-b1ec-f5770049d23e"> 
         <property name="com.jaspersoft.studio.unit.x" value="pixel"/> 
        </reportElement> 
        <box leftPadding="5"/> 
        <textElement textAlignment="Right" verticalAlignment="Middle"> 
         <font fontName="SansSerif" isBold="false"/> 
        </textElement> 
        <textFieldExpression><![CDATA[$P{runDate}]]></textFieldExpression> 
       </textField> 
      </band> 
     </pageFooter> 
    </jasperReport> 
+0

的问题是在你的报表(是不是在后),因为没有空间来打印的columnHeader?或groupHeader?它会打印它,如果你在subreport中使用groupHeader,你可以设置一个minHeight打印看到https://stackoverflow.com/questions/36740220/jrxml-eliminating-repeated-header-on-the-bottom –

+0

谢谢..它为我工作 –

回答

0

您正在使用一组产生的头,所以你可以使用这个属性minHeightToStartNewPage,以确定需要多大的空间来维持,否则突破新的一页。

<group name="DescriptionGroup" minHeightToStartNewPage="60"> 

,或者如果你想迫使它总是新的页面上开始

<group name="DescriptionGroup" isStartNewPage="true">