简体   繁体   English

如何在Jasper报告中显示ArrayList的值

[英]How to show value of ArrayList in jasper report

I am using jasper report 5. I am able to print simple variable values, but i am not getting how to print values of ArrayList variable. 我正在使用jasper report5。我能够打印简单的变量值,但是我没有得到如何打印ArrayList变量的值。

I have included 我已经包括

<field name="billNo" class="java.lang.Long"/>
    <field name="paymentType" class="java.lang.String"/>
    <field name="subTotal" class="java.lang.Float"/>
    <field name="vat" class="java.lang.Float"/>
    <field name="total" class="java.lang.Float"/>

I am printing above fields like 我在上面的字段上打印

 <textField>
        <reportElement x="276" y="70" width="180" height="15"/>
    <textElement/>
        <textFieldExpression><![CDATA[$F{total}]]></textFieldExpression>
    </textField>

same for others.That is working fine. 其他人也一样。

Now I have an ArrayList customerList . 现在我有一个ArrayList customerList which have fields customerName , address etc. 其中包含字段customerNameaddress等。

I want to show these values using jasper report how to do this. 我想使用jasper report显示这些值。

Create another subreport for Customer List like : 为客户列表创建另一个子报表,例如:

<subreport>
<reportElement x="0" y="0" width="0" height="0"></reportElement>
<subreportParameter name="SUBREPORT_DIR"><subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
</subreportParameter>
<dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{customerList})]]></dataSourceExpression>
<subreportExpression><![CDATA[$P{SUBREPORT_DIR} + "CustomerList.jasper"]]></subreportExpression>
</subreport>

In the new sub report 在新的子报告中

<textField>
        <reportElement x="276" y="70" width="180" height="15"/>
    <textElement/>
        <textFieldExpression><![CDATA[$F{customerName}]]></textFieldExpression>
    </textField>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM