繁体   English   中英

在Jasper报告中打印ArrayList值?

[英]Print ArrayList values in Jasper report?

我试图在Japer报告中打印ArrayList值,但问题是这是我作为输出得到的

2014-03-11,2014-03

但是我的数组列表“ adhist”应该被打印输出为(一对一)

2014-03-11
2014-03

这是我的Java Spring MVC代码

ArrayList<String> adhist = new ArrayList<String>();
    for(int i=0;i<Admission.size();i++){
        addhist.add(new AdmissionHistory());
        addhist.get(i).setAdmitdate(Admission.get(i).getAdmitdate());
        adhist.add(Admission.get(i).getAdmitdate());

        addhist.get(i).setDischargedate(Admission.get(i).getDischarge());
        if(Admission.get(i).getDischarge().equals("yes")){
        addhist.get(i).setDiagnosis(patientService.listdiagnosis(Admission.get(i).getAdmitclinicid()).get(0).getDiagnosis());
        }

        }
    model.put("adhist", adhist);
    modelAndView = new ModelAndView("pdfReportView1", model);

这是jasperreport.xml

<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="Patientsummerpdf" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="842" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="adhist" class="java.util.List"/>
<field name="fullname" class="java.lang.String"/>
<field name="address" class="java.lang.String"/>
<field name="dob" class="java.lang.String"/>
<field name="gender" class="java.lang.String"/>
<field name="height" class="java.lang.String"/>
<field name="weight" class="java.lang.String"/>
<field name="bloodgrp" class="java.lang.String"/>
<field name="immunstatus" class="java.lang.String"/>
<field name="developstatus" class="java.lang.String"/>
<background>
    <band splitType="Stretch"/>
</background>
<title>
    <band height="19" splitType="Stretch"/>
</title>
<pageHeader>
    <band height="30" splitType="Stretch"/>
</pageHeader>
<columnHeader>
    <band height="131" splitType="Stretch">
        <staticText>
            <reportElement x="24" y="60" width="68" height="20"/>
            <textElement/>
            <text><![CDATA[Full Name]]></text>
        </staticText>
        <staticText>
            <reportElement x="210" y="60" width="68" height="20"/>
            <textElement/>
            <text><![CDATA[Address]]></text>
        </staticText>
        <staticText>
            <reportElement x="396" y="60" width="68" height="20"/>
            <textElement/>
            <text><![CDATA[Date of Birth]]></text>
        </staticText>
        <staticText>
            <reportElement x="589" y="60" width="49" height="20"/>
            <textElement/>
            <text><![CDATA[Gender]]></text>
        </staticText>
        <textField>
            <reportElement x="92" y="60" width="100" height="20"/>
            <textElement/>
            <textFieldExpression class="java.lang.String"><![CDATA[$F{fullname}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="278" y="60" width="100" height="20"/>
            <textElement/>
            <textFieldExpression class="java.lang.String"><![CDATA[$F{address}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="464" y="60" width="100" height="20"/>
            <textElement/>
            <textFieldExpression class="java.lang.String"><![CDATA[$F{dob}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="638" y="60" width="61" height="20"/>
            <textElement/>
            <textFieldExpression class="java.lang.String"><![CDATA[$F{gender}]]></textFieldExpression>
        </textField>
        <staticText>
            <reportElement x="24" y="94" width="68" height="20"/>
            <textElement/>
            <text><![CDATA[Height]]></text>
        </staticText>
        <staticText>
            <reportElement x="210" y="94" width="68" height="20"/>
            <textElement/>
            <text><![CDATA[Weight]]></text>
        </staticText>
        <staticText>
            <reportElement x="396" y="94" width="68" height="20"/>
            <textElement/>
            <text><![CDATA[Blood Group]]></text>
        </staticText>
        <textField>
            <reportElement x="92" y="94" width="100" height="20"/>
            <textElement/>
            <textFieldExpression class="java.lang.String"><![CDATA[$F{height}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="278" y="94" width="100" height="20"/>
            <textElement/>
            <textFieldExpression class="java.lang.String"><![CDATA[$F{weight}]]></textFieldExpression>
        </textField>
        <textField>
            <reportElement x="464" y="94" width="100" height="20"/>
            <textElement/>
            <textFieldExpression class="java.lang.String"><![CDATA[$F{bloodgrp}]]></textFieldExpression>
        </textField>
        <staticText>
            <reportElement x="145" y="0" width="100" height="20"/>
            <textElement/>
            <text><![CDATA[adhist]]></text>
        </staticText>
    </band>
</columnHeader>
<detail>
    <band height="90" splitType="Stretch">
        <textField>
            <reportElement x="133" y="32" width="100" height="20"/>
            <textElement/>
            <textFieldExpression class="java.lang.String"><![CDATA[""+$P{adhist}]]></textFieldExpression>
        </textField>
    </band>
</detail>
<columnFooter>
    <band height="77" splitType="Stretch"/>
</columnFooter>
<pageFooter>
    <band height="37" splitType="Stretch"/>
</pageFooter>
<summary>
    <band height="42" splitType="Stretch"/>
</summary>
</jasperReport>

我认为您唯一需要的是使用jasper List组件包装参数。 您可以在iReports面板中找到它。 这是一个例子:

<jr:list xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd" printOrder="Vertical">
                <datasetRun subDataset="dataset1" uuid="a274a1ab-d0f4-430d-a8c2-d342a20ff672">
                    <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
                </datasetRun>
                <jr:listContents height="53" width="555">
                    <textField>
                        <reportElement uuid="7dd0769f-d7b6-4620-8e88-1ad3ca607e8d" x="2" y="0" width="100" height="20"/>
                        <textElement/>
                        <textFieldExpression><![CDATA[""+$P{adhist}]]></textFieldExpression>
                    </textField>
                </jr:listContents>
            </jr:list>

暂无
暂无

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

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