Java 是否在Jasper报告中打印ArrayList值?
我试图在Japer报告中打印ArrayList值,但问题是这是我作为输出得到的结果Java 是否在Jasper报告中打印ArrayList值?,java,spring-mvc,jasper-reports,Java,Spring Mvc,Jasper Reports,我试图在Japer报告中打印ArrayList值,但问题是这是我作为输出得到的结果 2014-03-11,2014-03 但是我的数组列表“adhist”应该打印输出为(一个接一个) 这是我的JavaSpringMVC代码 ArrayList<String> adhist = new ArrayList<String>(); for(int i=0;i<Admission.size();i++){ addhist.add(new Admis
2014-03-11,2014-03
但是我的数组列表“adhist”应该打印输出为(一个接一个)
这是我的JavaSpringMVC代码
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);
ArrayList adhist=new ArrayList();
对于(int i=0;i
我认为您只需要使用jasper列表组件来包装参数。您可以在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>
<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>
<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>