2016-04-26 164 views
1

使用Jaspersoft studio 6.2。isIgnorePagination如何分割到新頁面?

一個主要報告,包含詳細信息和彙總帶。主報告彙總區中的小組報告。主要報告本身(當沒有子報告時)將分成兩頁,因此我檢查了isIgnorePagination,主報告(當沒有子報告時)以單頁形式出現。

當我檢查isIgnorePagination它作爲一個單一頁面出現時,子報告本身默認分成9頁。精細。當我將子報表與上述所有設置一起放入主報表時,它會作爲一個頁面出現。我如何在一頁中製作主報告,在另一頁中製作子報表(總共兩頁)?

編輯

試圖休息部件,它的工作原理,但仍有一個問題。主報告的頁面高度必須設置得足夠大,以包括主報告和子報表,否則將會有2頁以上的頁面,但這會在主報告的底部留下太多空白。下面是一個例子來展示我的意思。

主報告

<?xml version="1.0" encoding="UTF-8"?> 
    <!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0 --> 
    <!-- 2016-04-26T16:13:43 --> 
    <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="test11" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="ce9d78e1-7194-4754-aaf9-93e871d2a5cf"> 
     <property name="com.jaspersoft.studio.data.sql.tables" value=""/> 
     <property name="com.jaspersoft.studio.data.defaultdataadapter" value="datamart"/> 
     <property name="com.jaspersoft.studio.unit." value="pixel"/> 
     <queryString> 
      <![CDATA[select 1 as a 
    union all select 2 as a]]> 
     </queryString> 
     <field name="a" class="java.lang.Integer"/> 
     <variable name="Total" class="java.lang.Integer" calculation="Sum"> 
      <variableExpression><![CDATA[$F{a}]]></variableExpression> 
     </variable> 
     <background> 
      <band splitType="Stretch"/> 
     </background> 
     <columnHeader> 
      <band height="50"> 
       <staticText> 
        <reportElement x="54" y="0" width="100" height="30" uuid="e9116c0f-c827-4cb3-95d1-9155f4be7cb7"/> 
        <text><![CDATA[a]]></text> 
       </staticText> 
      </band> 
     </columnHeader> 
     <detail> 
      <band height="49" splitType="Stretch"> 
       <textField> 
        <reportElement x="50" y="10" width="100" height="30" uuid="79fa53fa-48e2-43d0-96a4-0cda54e95c25"/> 
        <textFieldExpression><![CDATA[$F{a}]]></textFieldExpression> 
       </textField> 
      </band> 
     </detail> 
     <summary> 
      <band height="297" splitType="Stretch"> 
       <textField> 
        <reportElement mode="Opaque" x="52" y="16" width="100" height="30" backcolor="#C4E5F6" uuid="2a393151-947e-4f1d-ab24-e456ce56bd19"/> 
        <textFieldExpression><![CDATA[$V{Total}]]></textFieldExpression> 
       </textField> 
       <subreport> 
        <reportElement x="62" y="97" width="200" height="200" uuid="b342cbae-597b-4ca5-b00d-3a4d047910f8"/> 
        <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression> 
        <subreportExpression><![CDATA["test12.jasper"]]></subreportExpression> 
       </subreport> 
       <break> 
        <reportElement x="0" y="60" width="619" height="1" uuid="ccc2155d-6a2e-4c23-a972-88bb871cb17d"/> 
       </break> 
      </band> 
     </summary> 
    </jasperReport> 

子報告

<?xml version="1.0" encoding="UTF-8"?> 
    <!-- Created with Jaspersoft Studio version 6.2.0.final using JasperReports Library version 6.2.0 --> 
    <!-- 2016-04-26T16:14:10 --> 
    <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="test12" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="3601f813-f6da-4105-a4d8-5c1ee1dd54d4"> 
     <property name="com.jaspersoft.studio.data.sql.tables" value=""/> 
     <property name="com.jaspersoft.studio.data.defaultdataadapter" value="datamart"/> 
     <queryString> 
      <![CDATA[select 10 as col 
    union all select 20 as col]]> 
     </queryString> 
     <field name="col" class="java.lang.Integer"/> 
     <variable name="total" class="java.lang.Integer" calculation="Sum"> 
      <variableExpression><![CDATA[$F{col}]]></variableExpression> 
     </variable> 
     <background> 
      <band splitType="Stretch"/> 
     </background> 
     <columnHeader> 
      <band height="61" splitType="Stretch"> 
       <staticText> 
        <reportElement x="73" y="0" width="100" height="30" uuid="5f2cfa26-c7ab-413e-94cf-80c1f1b288eb"/> 
        <text><![CDATA[col]]></text> 
       </staticText> 
      </band> 
     </columnHeader> 
     <detail> 
      <band height="125" splitType="Stretch"> 
       <textField> 
        <reportElement x="73" y="90" width="100" height="30" uuid="3af983fb-00e2-4bb9-9e91-2d2214ca95d7"/> 
        <textFieldExpression><![CDATA[$F{col}]]></textFieldExpression> 
       </textField> 
      </band> 
     </detail> 
     <summary> 
      <band height="49" splitType="Stretch"> 
       <textField> 
        <reportElement mode="Opaque" x="74" y="19" width="100" height="30" backcolor="#FFCC33" uuid="b333fb92-8aa8-4f00-9a1a-db24657d5521"/> 
        <textFieldExpression><![CDATA[$V{total}]]></textFieldExpression> 
       </textField> 
      </band> 
     </summary> 
    </jasperReport> 

有主報告中休息,這工作正常,2個一個主報告和一個頁面子報告,但主報告在底部留下太多空白,如果我減少主報告的高度(例如400像素),則會有2頁以上。沒有太多的空白可以得到2頁嗎?

+0

使用標題帶,細節帶區(主報告)及摘要帶(報表)與屬性isSummaryNewPage =「true」,並且您有兩個頁面或使用中斷組件。似乎很奇怪,你需要使用IgnorePagination,你可以創建一個[mcve] –

+0

嗨,我是新來的碧玉報告。我在哪裏可以找到isSummaryNewPage或中斷組件? – thotwielder

+0

isSummaryNewPage是jasperReport標籤上的一個屬性(如果您選擇根結構標籤,您可以在屬性中找到它)。 break是一個包含分頁符或分欄符的組件(如果您使用IDE,可以在調色板中找到它) –

回答

1

要實現每個頁面的不同大小,您需要使用jasperReport標記上的屬性isIgnorePagination="true"

isIgnorePagination是真實的突破元素默認被忽略掉你需要啓用它通過設置該屬性net.sf.jasperreports.page.break.no.paginationapply

忽略 - 分頁非分頁報表被忽略。 (默認)
apply -  分頁符在非分頁報告中很有用。

<property name="net.sf.jasperreports.page.break.no.pagination" value="apply"/> 

這將使破組件,您可以MANUALE突破到新的頁面使用

<break> 
    <reportElement x="0" y="0" width="100" height="1" uuid="604c65b5-1127-4874-a63c-9b1a98dbf25c"/> 
</break> 
+0

該設置確實會生成兩個單獨的頁面。但似乎主要或第一次報告將調整大小以適應彙總區域中的子報表。所以主要報告仍然有巨大的空白。我的例子並不明顯,但您可以通過更改子報表中的查詢來生成更多詳細信息,從而輕鬆測試它,以便您能夠看到問題。 – thotwielder

+0

您已將isIgnorePagination =「true」並將pageHeight設置爲最小值? –

+0

是的,isIgnorePagination =「true」,對於主高= 250,子報表高度= 400,兩者都是最小值(低於那麼它將報告它不能適應頁面高度的錯誤),但是第一個報告顯示頁面可能有幾千像素的高度,並在報告下面有巨大的空白。原因是子報表現在顯示了更多的細節(請記住我已更改查詢)。你可以測試它,查詢是通用的。 – thotwielder