Jaspersoft List元素只重复最后一个元素

问题描述 投票:0回答:1

我正在使用 TIBCO Jaspersoft® Studio 6.19.0 - JasperReports 6.19.0 的可视化设计器。 我有一个包含列表元素的报告,我正在使用 JRBeanCollectionDataSource。

我把列表放在一个细节带中,当我传递一个包含 3 个不同元素的列表时,它重复 3 次,但只显示列表的最后一个元素。

这是我的报告:这是第一个数据集名称 = vehicleList 的列表。

我试过一个子报告,它是相同的行为。

有人看到不顺利的地方吗?

谢谢

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.19.0.final using JasperReports Library version 6.19.0-646c68931cebf1a58bc65c4359d1f0ca223c5e94  -->
<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="ConditionsParticulieresFAAF" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="df013db5-f76e-44d3-b0df-bcbc46d93160">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
    <property name="net.sf.jasperreports.export.xls.ignore.graphics" value="false"/>
    <property name="com.jaspersoft.studio.unit." value="pixel"/>
    <property name="com.jaspersoft.studio.unit.pageHeight" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.pageWidth" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.topMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.bottomMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.leftMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.rightMargin" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.columnWidth" value="pixel"/>
    <property name="com.jaspersoft.studio.unit.columnSpacing" value="pixel"/>
    <style name="Title" fontName="Times New Roman" fontSize="50" isBold="true"/>
    <style name="Detail" fontName="Arial" fontSize="12"/>
    <style name="Row" mode="Transparent">
        <conditionalStyle>
            <conditionExpression><![CDATA[$V{REPORT_COUNT}%2 == 0]]></conditionExpression>
            <style backcolor="#E6DAC3"/>
        </conditionalStyle>
    </style>
    <style name="Table_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table 1_TH" mode="Opaque" backcolor="#F0F8FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table 1_CH" mode="Opaque" backcolor="#BFE1FF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <style name="Table 1_TD" mode="Opaque" backcolor="#FFFFFF">
        <box>
            <pen lineWidth="0.5" lineColor="#000000"/>
            <topPen lineWidth="0.5" lineColor="#000000"/>
            <leftPen lineWidth="0.5" lineColor="#000000"/>
            <bottomPen lineWidth="0.5" lineColor="#000000"/>
            <rightPen lineWidth="0.5" lineColor="#000000"/>
        </box>
    </style>
    <subDataset name="VehicleDataset" uuid="1510f21b-1251-4f64-8490-e724e9f8e79c">
        <queryString>
            <![CDATA[]]>
        </queryString>
        <field name="vehicleDescription" class="java.lang.String"/>
        <field name="plateNumber" class="java.lang.String"/>
        <field name="vehicleUsage" class="java.lang.String"/>
    </subDataset>
    <subDataset name="CoverageDataSet" uuid="eb4d7895-eb23-41c7-ae69-bc2701600d17">
        <property name="com.jaspersoft.studio.data.defaultdataadapter" value="One Empty Record"/>
        <queryString>
            <![CDATA[]]>
        </queryString>
        <field name="coverageName" class="java.lang.String"/>
        <field name="coverageAmount" class="java.lang.Double"/>
    </subDataset>
    <parameter name="CollectionBeanParam" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
    <parameter name="imageDir" class="java.lang.String" evaluationTime="Late">
        <defaultValueExpression><![CDATA["."]]></defaultValueExpression>
    </parameter>
    <parameter name="logo" class="java.lang.Object"/>
    <parameter name="companyName" class="java.lang.String"/>
    <parameter name="policyNumber" class="java.lang.String"/>
    <parameter name="insuredName" class="java.lang.String"/>
    <parameter name="effectiveDate" class="java.lang.String"/>
    <parameter name="expirationDate" class="java.lang.String"/>
    <parameter name="vehicleList" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
    <parameter name="coverageList" class="net.sf.jasperreports.engine.data.JRBeanCollectionDataSource"/>
    <queryString>
        <![CDATA[]]>
    </queryString>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="184" splitType="Prevent">
            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
            <image isLazy="true">
                <reportElement x="0" y="0" width="180" height="170" uuid="1c003177-754c-448f-8ce1-16868856f545">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                </reportElement>
                <imageExpression><![CDATA[$P{logo}]]></imageExpression>
            </image>
            <staticText>
                <reportElement style="Title" x="180" y="50" width="375" height="62" uuid="bc1ce1da-8232-46ea-be55-cec4abb986dd">
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <textElement textAlignment="Center" verticalAlignment="Middle">
                    <font fontName="SansSerif" size="20"/>
                </textElement>
                <text><![CDATA[Conditions particulières assurance habitation F.A.A.F
]]></text>
            </staticText>
        </band>
    </title>
    <detail>
        <band height="185">
            <property name="com.jaspersoft.studio.unit.height" value="px"/>
            <textField textAdjust="StretchHeight" evaluationTime="Report">
                <reportElement x="160" y="2" width="395" height="30" uuid="565db3d5-1a9c-49e2-b42a-69a39af320bc">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <textFieldExpression><![CDATA[$P{companyName}]]></textFieldExpression>
            </textField>
            <textField textAdjust="StretchHeight" evaluationTime="Report">
                <reportElement x="160" y="32" width="395" height="30" uuid="32ad2a97-feb8-4af5-b270-4704c77af7b8">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                </reportElement>
                <textFieldExpression><![CDATA["Condition générales du fonds d’assurance de responsabilité civile obligatoire (F.A.A.F)"]]></textFieldExpression>
            </textField>
            <textField textAdjust="StretchHeight" evaluationTime="Report">
                <reportElement x="0" y="2" width="160" height="30" uuid="3bce9c45-e6a4-4059-a2e8-20c4045c34b3">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["Compagnie d'assurance : "]]></textFieldExpression>
            </textField>
            <textField textAdjust="StretchHeight" evaluationTime="Report">
                <reportElement x="0" y="32" width="160" height="30" uuid="ed065c43-7f92-4b69-8468-4aafc3cd9cd2">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["Conditions Générales : "]]></textFieldExpression>
            </textField>
            <textField textAdjust="StretchHeight" evaluationTime="Report">
                <reportElement x="0" y="62" width="160" height="30" uuid="65c8f897-939b-449d-abc2-81803e2cc00f">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["Numéro de police : "]]></textFieldExpression>
            </textField>
            <textField textAdjust="StretchHeight" evaluationTime="Report">
                <reportElement x="160" y="62" width="395" height="30" uuid="5158ad4e-3446-4e6b-9350-17b654803fb7">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                </reportElement>
                <textFieldExpression><![CDATA[$P{policyNumber}]]></textFieldExpression>
            </textField>
            <textField textAdjust="StretchHeight" evaluationTime="Report">
                <reportElement x="0" y="92" width="160" height="30" uuid="1c858c3f-35a7-4791-9fe8-93366b134ce5">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["Preneur d’assurance : "]]></textFieldExpression>
            </textField>
            <textField textAdjust="StretchHeight" evaluationTime="Report">
                <reportElement x="160" y="92" width="395" height="30" uuid="ac47443f-905e-402b-8f7c-28e571d6d25f">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                </reportElement>
                <textFieldExpression><![CDATA[$P{insuredName}]]></textFieldExpression>
            </textField>
            <textField textAdjust="StretchHeight" evaluationTime="Report">
                <reportElement x="0" y="152" width="160" height="30" uuid="abbe9ba9-07af-4500-8039-18dd124a5a6d">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["Echéance : "]]></textFieldExpression>
            </textField>
            <textField textAdjust="StretchHeight" evaluationTime="Report">
                <reportElement x="0" y="122" width="160" height="30" uuid="2da4806d-3f73-4f11-9f11-f4bb0dbaba77">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <textElement>
                    <font size="12" isBold="true"/>
                </textElement>
                <textFieldExpression><![CDATA["Souscription : "]]></textFieldExpression>
            </textField>
            <textField textAdjust="StretchHeight" evaluationTime="Report">
                <reportElement x="160" y="122" width="395" height="30" uuid="ac61177d-2237-477e-905f-81e12bb448c7">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <textFieldExpression><![CDATA[$P{effectiveDate}]]></textFieldExpression>
            </textField>
            <textField textAdjust="StretchHeight" evaluationTime="Report">
                <reportElement x="160" y="152" width="395" height="30" uuid="061b5f8c-127c-40d2-8068-6189a06b368d">
                    <property name="com.jaspersoft.studio.unit.x" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <textFieldExpression><![CDATA[$P{expirationDate}]]></textFieldExpression>
            </textField>
        </band>
        <band height="123" splitType="Immediate">
            <componentElement>
                <reportElement x="0" y="0" width="555" height="123" uuid="eb4eebd3-2bdd-4dbc-83ff-79c14d2ed9e8">
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <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="VehicleDataset" uuid="4eefeaf4-9a54-46f8-9373-55bb54ba1ece">
                        <dataSourceExpression><![CDATA[$P{vehicleList}]]></dataSourceExpression>
                    </datasetRun>
                    <jr:listContents height="123" width="555">
                        <textField textAdjust="StretchHeight" evaluationTime="Report">
                            <reportElement x="0" y="2" width="160" height="30" uuid="298affca-8134-4ce7-8c3d-1ea52fd28472">
                                <property name="com.jaspersoft.studio.unit.x" value="px"/>
                                <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                                <property name="com.jaspersoft.studio.unit.width" value="px"/>
                            </reportElement>
                            <textElement>
                                <font size="12" isBold="true"/>
                            </textElement>
                            <textFieldExpression><![CDATA["Description du bien : "]]></textFieldExpression>
                        </textField>
                        <textField textAdjust="StretchHeight" evaluationTime="Report">
                            <reportElement x="160" y="2" width="390" height="30" uuid="69e49f8c-e245-4937-944a-159f5b69213d">
                                <property name="com.jaspersoft.studio.unit.x" value="px"/>
                            </reportElement>
                            <textFieldExpression><![CDATA[$F{vehicleDescription}]]></textFieldExpression>
                        </textField>
                        <textField textAdjust="StretchHeight" evaluationTime="Report">
                            <reportElement x="0" y="32" width="160" height="30" uuid="75ccaa12-2ca5-41fe-aa12-201427ff4431">
                                <property name="com.jaspersoft.studio.unit.x" value="px"/>
                                <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                                <property name="com.jaspersoft.studio.unit.width" value="px"/>
                            </reportElement>
                            <textElement>
                                <font size="12" isBold="true"/>
                            </textElement>
                            <textFieldExpression><![CDATA["Immatriculation : "]]></textFieldExpression>
                        </textField>
                        <textField textAdjust="StretchHeight" evaluationTime="Report">
                            <reportElement x="160" y="32" width="390" height="30" uuid="52272038-0eac-4c32-9078-f63e88140a9f">
                                <property name="com.jaspersoft.studio.unit.x" value="px"/>
                            </reportElement>
                            <textFieldExpression><![CDATA[$F{plateNumber}]]></textFieldExpression>
                        </textField>
                        <textField textAdjust="StretchHeight" evaluationTime="Report">
                            <reportElement x="0" y="63" width="160" height="30" uuid="e9b8e970-8458-4095-b90a-51148e33a719">
                                <property name="com.jaspersoft.studio.unit.x" value="px"/>
                                <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                                <property name="com.jaspersoft.studio.unit.width" value="px"/>
                            </reportElement>
                            <textElement>
                                <font size="12" isBold="true"/>
                            </textElement>
                            <textFieldExpression><![CDATA["Usage du véhicule : "]]></textFieldExpression>
                        </textField>
                        <textField textAdjust="StretchHeight" evaluationTime="Report">
                            <reportElement x="160" y="63" width="390" height="30" uuid="5487c2bf-8c32-49ac-b2d2-488a76ee66ff">
                                <property name="com.jaspersoft.studio.unit.x" value="px"/>
                            </reportElement>
                            <textFieldExpression><![CDATA[$F{vehicleUsage}]]></textFieldExpression>
                        </textField>
                        <textField textAdjust="StretchHeight" evaluationTime="Report">
                            <reportElement x="0" y="93" width="160" height="30" uuid="4c6ead46-f059-43c2-b398-0193e05345b6">
                                <property name="com.jaspersoft.studio.unit.x" value="px"/>
                                <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                                <property name="com.jaspersoft.studio.unit.width" value="px"/>
                            </reportElement>
                            <textElement>
                                <font size="12" isBold="true"/>
                            </textElement>
                            <textFieldExpression><![CDATA["Garantie couverte : "]]></textFieldExpression>
                        </textField>
                        <textField textAdjust="StretchHeight" evaluationTime="Report">
                            <reportElement x="160" y="93" width="390" height="30" uuid="5e917781-163b-4a46-846c-59cb83c86ec3">
                                <property name="com.jaspersoft.studio.unit.x" value="px"/>
                            </reportElement>
                            <textFieldExpression><![CDATA["suivant les conditions générales F.A.A.F."]]></textFieldExpression>
                        </textField>
                    </jr:listContents>
                </jr:list>
            </componentElement>
        </band>
        <band height="63">
            <property name="com.jaspersoft.studio.unit.height" value="px"/>
            <componentElement>
                <reportElement x="0" y="30" width="555" height="32" uuid="e3cd8129-df9d-40c5-a556-21cc25860c11">
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.height" value="pixel"/>
                </reportElement>
                <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="CoverageDataSet" uuid="352d365b-7775-42f0-ac5c-97d457e14a8f">
                        <dataSourceExpression><![CDATA[$P{coverageList}]]></dataSourceExpression>
                    </datasetRun>
                    <jr:listContents height="32" width="555">
                        <textField textAdjust="StretchHeight" evaluationTime="Report">
                            <reportElement x="0" y="2" width="160" height="30" uuid="8e61ba8d-08df-4044-beae-b6790447ca42">
                                <property name="com.jaspersoft.studio.unit.x" value="px"/>
                                <property name="com.jaspersoft.studio.unit.y" value="pixel"/>
                                <property name="com.jaspersoft.studio.unit.width" value="px"/>
                            </reportElement>
                            <textElement>
                                <font size="12" isBold="true"/>
                            </textElement>
                            <textFieldExpression><![CDATA[" \t▪" +  $F{coverageName} + " : "]]></textFieldExpression>
                        </textField>
                        <textField textAdjust="StretchHeight" evaluationTime="Report">
                            <reportElement x="160" y="2" width="395" height="30" uuid="d793ddad-9fd6-434c-aeb8-fb799735e538">
                                <property name="com.jaspersoft.studio.unit.x" value="px"/>
                                <property name="com.jaspersoft.studio.unit.width" value="px"/>
                            </reportElement>
                            <textFieldExpression><![CDATA[new DecimalFormat("0.00").format($F{coverageAmount}) + " FCFA"]]></textFieldExpression>
                        </textField>
                    </jr:listContents>
                </jr:list>
            </componentElement>
            <staticText>
                <reportElement x="0" y="2" width="555" height="30" uuid="ab0eab79-c843-431a-afac-de9f1b08bbf8">
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <textElement>
                    <font size="12"/>
                </textElement>
                <text><![CDATA[Valeur assurée :]]></text>
            </staticText>
        </band>
        <band height="97">
            <staticText>
                <reportElement x="0" y="2" width="290" height="30" uuid="029cd098-b26b-4e90-b72c-24dc29a27682"/>
                <textElement>
                    <font size="12" isUnderline="true"/>
                </textElement>
                <text><![CDATA[Intervention maximale de la compagnie d’assurance : ]]></text>
            </staticText>
            <staticText>
                <reportElement x="290" y="2" width="265" height="30" uuid="afdc55cc-8853-4bf1-a5c5-193a42a9a27b">
                    <property name="com.jaspersoft.studio.unit.y" value="px"/>
                    <property name="com.jaspersoft.studio.unit.width" value="px"/>
                </reportElement>
                <textElement>
                    <font size="12"/>
                </textElement>
                <text><![CDATA[en premier risque]]></text>
            </staticText>
            <staticText>
                <reportElement x="0" y="24" width="290" height="70" uuid="a1f868cf-e1ef-4083-ac5a-859aa72124e6">
                    <property name="com.jaspersoft.studio.unit.width" value="pixel"/>
                </reportElement>
                <textElement>
                    <font size="12"/>
                </textElement>
                <text><![CDATA[     ▪   VOL : 100%
     ▪  Dommage : 100%
     ▪  Perte totale :  100%
     ▪  Tierce-Collision : 100%
]]></text>
            </staticText>
        </band>
        <band height="151">
            <staticText>
                <reportElement x="0" y="2" width="290" height="30" uuid="5246f695-2e1f-4c1f-9b14-5151c4187679"/>
                <textElement>
                    <font size="12"/>
                </textElement>
                <text><![CDATA[Date et signature du client]]></text>
            </staticText>
            <rectangle radius="13">
                <reportElement x="0" y="42" width="290" height="100" uuid="d2bb9d66-05da-48c3-96cc-358105000b83"/>
                <graphicElement>
                    <pen lineColor="#59995B"/>
                </graphicElement>
            </rectangle>
        </band>
    </detail>
    <pageFooter>
        <band splitType="Stretch"/>
    </pageFooter>
    <summary>
        <band splitType="Stretch"/>
    </summary>
</jasperReport>

这是java代码:

import net.sf.jasperreports.engine.*;
import net.sf.jasperreports.engine.data.JRBeanCollectionDataSource;

import java.io.File;
import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.UUID;

public class ConditionParticuliereFaafMain {

   public static void main(String[] args) throws JRException, IOException {

        // Compile jrxml file.
       JasperReport jasperReport = JasperCompileManager
               .compileReport("C:\\DEV\\Projets\\backend\\services\\src\\main\\resources\\reports\\ConditionsParticulieresFAAF.jrxml");

       // Parameters for report
       List<ConditionParticuliereVehicleDto> vehicleDtoList = List.of(buildVehicleDto("Toyota"), buildVehicleDto("BMW"), buildVehicleDto("RAM"));
       JRBeanCollectionDataSource vehicleListDataSource = new JRBeanCollectionDataSource(vehicleDtoList);

       List<ConditionParticuliereCoverageDto> coverageDtoList = List.of(buildCoverageDto(), buildCoverageDto());
       JRBeanCollectionDataSource coverageListDataSource = new JRBeanCollectionDataSource(coverageDtoList);
       Map<String, Object> parameters = new HashMap();
       //parameters.put("logo", image);
       parameters.put("vehicleList", vehicleListDataSource);
       parameters.put("coverageList", coverageListDataSource);
       parameters.put("companyName", "Toto Inc");
       parameters.put("policyNumber", "P-15488");
       parameters.put("insuredName", "Toto Jean");
       parameters.put("effectiveDate", "2023-02-19");
       parameters.put("expirationDate", "2024-02-19");

       // DataSource
       // This is simple example, no database.
       // then using empty datasource.
       JRDataSource dataSource = new JREmptyDataSource();

       JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,
               parameters, dataSource);

   
       // Make sure the output directory exists.
       File outDir = new File("C:/jasperoutput");
       outDir.mkdirs();

       // Export to PDF.
       JasperExportManager.exportReportToPdfFile(jasperPrint,
               "C:/jasperoutput/" + UUID.randomUUID().toString() + ".pdf");
       
       System.out.println("Done!");
   }

    private static ConditionParticuliereCoverageDto buildCoverageDto() {
       return ConditionParticuliereCoverageDto.builder()
               .coverageAmount(200000.0)
               .coverageName("Vol - Vol Simple")
               .build();
    }

    private static ConditionParticuliereVehicleDto buildVehicleDto(String brand) {
       return ConditionParticuliereVehicleDto.builder()
               .plateNumber("plate number")
               .vehicleUsage("Véhicle usage")
               .vehicleDescription(brand + " Rav4 2014 Mx544545554")
               .build();
    }
}
jasper-reports
1个回答
0
投票

终于找到答案了。将列表中文本字段的评估时间设置为“自动”

© www.soinside.com 2019 - 2024. All rights reserved.