2012-06-13 75 views
2

我正在生成pdfJasperReports以XML作爲數據源。如何在JasperReports中進行分組?

我有表像 enter image description here

和XML是如下:

<multiplerecord type="PAF_DETAILS"> 
    <record PAFNO="PAF121" MINCOMM="5" INVOICENO="BILL000000121" TYPE="Exclusive" CATEGORY="Category I" SLABNO="Slab 1"/> 
    <record PAFNO="PAF122" MINCOMM="5" INVOICENO="BILL000000122" TYPE="Exclusive" CATEGORY="Category I" SLABNO="Slab 1"/> 
    <record PAFNO="PAF123" MINCOMM="5" INVOICENO="BILL000000123" TYPE="Exclusive" CATEGORY="Category I" SLABNO="Slab 1"/> 
    <record PAFNO="PAF124" MINCOMM="5" INVOICENO="BILL000000124" TYPE="Exclusive" CATEGORY="Category I" SLABNO="Slab 1"/> 
    <record PAFNO="PAF125" MINCOMM="5" INVOICENO="BILL000000125" TYPE="Exclusive" CATEGORY="Category I" SLABNO="Slab 1"/> 
    <record PAFNO="PAF124" MINCOMM="5" INVOICENO="BILL000000124" TYPE="Exclusive" CATEGORY="Category I" SLABNO="Slab 2"/> 
    <record PAFNO="PAF122" MINCOMM="5" INVOICENO="BILL000000122" TYPE="Exclusive" CATEGORY="Category I" SLABNO="Slab 2"/> 
    <record PAFNO="PAF123" MINCOMM="5" INVOICENO="BILL000000123" TYPE="Exclusive" CATEGORY="Category I" SLABNO="Slab 2"/> 
    <record PAFNO="PAF126" MINCOMM="5" INVOICENO="BILL000000126" TYPE="Non - Exclusive" CATEGORY="Category I" SLABNO="Slab 1"/> 
    <record PAFNO="PAF127" MINCOMM="5" INVOICENO="BILL000000127" TYPE="Non - Exclusive" CATEGORY="Category I" SLABNO="Slab 1"/> 
    <record PAFNO="PAF128" MINCOMM="5" INVOICENO="BILL000000128" TYPE="Non - Exclusive" CATEGORY="Category I" SLABNO="Slab 1"/> 
    </multiplerecord> 

如何這是的JasperReports實現與的iReport 4.5.1
我是JR的新手。

在此先感謝。

+1

你可以閱讀[這個常見問題在jasperforge.org](http://jasperforge.org/uploads/publish/jasperreportswebsite/trunk/sample.reference/jasper/index.html#groups) –

回答

1

您可以使用:

<group name="Type"> 
    <groupExpression><![CDATA[$F{TYPE}]]></groupExpression> 
</group> 

該組可以包含組頭,組頁腳...你可以使用的JasperReport多個組。確保數據正確排序,排序應符合定義的組。在你的例子中排序似乎已經確定。您可以在iReport設計器中輕鬆定義組。