我已经使用ireport工具创建了主要和次要碧玉报告。
下面是我创建的报告的详细信息
主要报告:
<?xml version="1.0" encoding="UTF-8"?>
<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="report1" language="groovy" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c378ac54-562d-4302-8bac-8afca44b5089">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false">
<defaultValueExpression><![CDATA["C:\\hitesh\\JasperDemo2\\resource\\"]]></defaultValueExpression>
</parameter>
<queryString language="xPath">
<![CDATA[custominfo/multiplerecord]]>
</queryString>
<field name="ADATE" class="java.lang.String">
<fieldDescription><![CDATA[/custominfo/singlerecord/@ADATE]]></fieldDescription>
</field>
<field name="AMOUNT" class="java.lang.String">
<fieldDescription><![CDATA[/custominfo/singlerecord/@AMOUNT]]></fieldDescription>
</field>
<field name="BANK" class="java.lang.String">
<fieldDescription><![CDATA[/custominfo/singlerecord/@BANK]]></fieldDescription>
</field>
<field name="BRANCH" class="java.lang.String">
<fieldDescription><![CDATA[/custominfo/singlerecord/@BRANCH]]></fieldDescription>
</field>
<field name="RDATE" class="java.lang.String">
<fieldDescription><![CDATA[/custominfo/singlerecord/@RDATE]]></fieldDescription>
</field>
<field name="REFNO" class="java.lang.String">
<fieldDescription><![CDATA[/custominfo/singlerecord/@REFNO]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<columnHeader>
<band height="168">
<staticText>
<reportElement x="1" y="1" width="552" height="20" uuid="ea996077-bb25-4940-bf74-4c8e1d443faa"/>
<textElement textAlignment="Center">
<font size="14" isBold="true" isUnderline="true"/>
</textElement>
<text><![CDATA[Due Diligence Report For Housing & Mortgage Loan Process]]></text>
</staticText>
<staticText>
<reportElement x="1" y="35" width="189" height="21" uuid="69d14272-90dd-4de2-8120-03add35e81a6"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Reporting bank]]></text>
</staticText>
<staticText>
<reportElement x="1" y="57" width="189" height="21" uuid="0447487b-8478-4e1e-9b7a-92b745a36a22"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Branch]]></text>
</staticText>
<staticText>
<reportElement x="1" y="79" width="189" height="21" uuid="931c958d-13ef-4387-951d-bb1a0dcbcb08"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Loan Application Amount]]></text>
</staticText>
<staticText>
<reportElement x="1" y="101" width="189" height="21" uuid="395dbcf2-b0a2-4611-80d0-a47fc1533853"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Assignment Date]]></text>
</staticText>
<staticText>
<reportElement x="1" y="123" width="189" height="21" uuid="31ea40ba-f128-48cd-943a-a5c3e962056f"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Report Date]]></text>
</staticText>
<staticText>
<reportElement x="1" y="145" width="189" height="21" uuid="d129f4f0-1c89-4815-9c33-514453b2385a"/>
<textElement>
<font size="12" isBold="true"/>
</textElement>
<text><![CDATA[Report Ref. Sr. No.]]></text>
</staticText>
<line>
<reportElement x="0" y="56" width="555" height="1" uuid="88408577-afee-4e4d-b60b-789b3c2ffeec"/>
</line>
<line>
<reportElement x="0" y="78" width="555" height="1" uuid="4bed497d-24d9-4801-b270-02fd98410a1c"/>
</line>
<line>
<reportElement x="0" y="100" width="555" height="1" uuid="93223947-5c1e-46ea-9a85-6eab5ff6da56"/>
</line>
<line>
<reportElement x="0" y="122" width="555" height="1" uuid="5a5e5c45-dd3d-423e-92ea-16b1ec1e7e46"/>
</line>
<line>
<reportElement x="0" y="144" width="555" height="1" uuid="0e50dcad-5f16-4d24-8ef0-b9e690d633b4"/>
</line>
<line>
<reportElement x="0" y="167" width="555" height="1" uuid="e80968e3-b1f8-4a23-8f0d-944da30db585"/>
</line>
<textField>
<reportElement x="191" y="36" width="364" height="20" uuid="8e763775-e917-476b-a48d-59e43339840f"/>
<textFieldExpression><![CDATA[$F{BANK}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="191" y="58" width="364" height="20" uuid="4ebda466-ee22-4a77-b81f-8c8c0c42648d"/>
<textFieldExpression><![CDATA[$F{BRANCH}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="191" y="79" width="364" height="20" uuid="3039c063-1613-4e54-9731-253335c00472"/>
<textFieldExpression><![CDATA[$F{AMOUNT}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="191" y="101" width="364" height="20" uuid="7b3e5d63-bdd4-4b45-af23-fcc6b11f3c37"/>
<textFieldExpression><![CDATA[$F{ADATE}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="191" y="124" width="364" height="20" uuid="e290e21a-26de-4e81-9e9d-1f5e2f8e3920"/>
<textFieldExpression><![CDATA[$F{RDATE}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="191" y="146" width="364" height="20" uuid="de142a3d-45c8-4990-aca9-4ca74e9aa702"/>
<textFieldExpression><![CDATA[$F{REFNO}]]></textFieldExpression>
</textField>
<line>
<reportElement x="190" y="35" width="1" height="21" uuid="3af51f75-0611-494f-aee2-f30179824a23"/>
</line>
<line>
<reportElement x="190" y="57" width="1" height="21" uuid="ff227276-d6d0-4b41-93b0-bc2f2438bb0e"/>
</line>
<line>
<reportElement x="190" y="79" width="1" height="21" uuid="96408275-181f-4d55-bab5-218769ac9e08"/>
</line>
<line>
<reportElement x="190" y="101" width="1" height="21" uuid="609961b0-b127-48bc-82f1-224ae7437359"/>
</line>
<line>
<reportElement x="190" y="123" width="1" height="21" uuid="45e26d7e-6b63-4dbc-b390-c265d82bf9d1"/>
</line>
<line>
<reportElement x="190" y="145" width="1" height="21" uuid="418cd970-ae35-48ff-aa1f-656b969bbf2e"/>
</line>
<line>
<reportElement x="0" y="35" width="1" height="21" uuid="97d6df92-411c-4c2d-ab40-99ea10222702"/>
</line>
<line>
<reportElement x="0" y="57" width="1" height="21" uuid="a1c65914-1293-4986-96e1-0542d425f7ec"/>
</line>
<line>
<reportElement x="0" y="101" width="1" height="21" uuid="98050f8c-8909-4910-9c08-5a4957da8ae1"/>
</line>
<line>
<reportElement x="0" y="123" width="1" height="21" uuid="b49e491b-593f-4786-b94d-7ba8b8b7ac0f"/>
</line>
<line>
<reportElement x="0" y="146" width="1" height="21" uuid="53ec9718-4e23-4815-a527-4612ced3d68d"/>
</line>
<line>
<reportElement x="0" y="34" width="555" height="1" uuid="2de5a889-dd1a-45ce-8dc9-133a22e035e3"/>
</line>
<line>
<reportElement x="0" y="79" width="1" height="21" uuid="d713b5a2-2b60-48fb-8eb8-ecef6fe558cc"/>
</line>
<line>
<reportElement x="555" y="34" width="1" height="21" uuid="374b13b5-8b5c-482e-8df7-17872df35e52"/>
</line>
<line>
<reportElement x="555" y="56" width="1" height="21" uuid="8bddc232-2194-4ea9-8d27-7292b81c2338"/>
</line>
<line>
<reportElement x="555" y="77" width="1" height="22" uuid="258c96a2-f5ea-4277-9dba-eb420697772f"/>
</line>
<line>
<reportElement x="555" y="101" width="1" height="21" uuid="82966cec-d564-4d72-a30a-d87d8054b59a"/>
</line>
<line>
<reportElement x="555" y="122" width="1" height="21" uuid="15b0edb9-5f43-452c-a511-5d574cf05e98"/>
</line>
<line>
<reportElement x="555" y="144" width="1" height="22" uuid="cc394272-7b66-403e-8f04-e7ff982b79d5"/>
</line>
</band>
</columnHeader>
<detail>
<band height="100" splitType="Stretch">
<subreport>
<reportElement isPrintRepeatedValues="false" x="0" y="0" width="551" height="100" uuid="3e117990-7e70-4224-858b-d7bc43057c3d"/>
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JRXmlDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("//summary/record")]]></dataSourceExpression>
<subreportExpression><![CDATA["report1_subreport1.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
</jasperReport>
子报告
<?xml version="1.0" encoding="UTF-8"?>
<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="report1_subreport1" language="groovy" pageWidth="555" pageHeight="802" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="ac2acac4-505d-41e0-a715-851795c6a6d1">
<property name="ireport.zoom" value="1.0"/>
<property name="ireport.x" value="0"/>
<property name="ireport.y" value="0"/>
<queryString language="xPath">
<![CDATA[/custominfo/multiplerecord/summary/record]]>
</queryString>
<field name="BRANCH" class="java.lang.String">
<fieldDescription><![CDATA[/custominfo/singlerecord/@BRANCH]]></fieldDescription>
</field>
<field name="ADATE" class="java.lang.String">
<fieldDescription><![CDATA[/custominfo/singlerecord/@ADATE]]></fieldDescription>
</field>
<field name="AMOUNT" class="java.lang.String">
<fieldDescription><![CDATA[/custominfo/singlerecord/@AMOUNT]]></fieldDescription>
</field>
<field name="BANK" class="java.lang.String">
<fieldDescription><![CDATA[/custominfo/singlerecord/@BANK]]></fieldDescription>
</field>
<field name="RDATE" class="java.lang.String">
<fieldDescription><![CDATA[/custominfo/singlerecord/@RDATE]]></fieldDescription>
</field>
<field name="REFNO" class="java.lang.String">
<fieldDescription><![CDATA[/custominfo/singlerecord/@REFNO]]></fieldDescription>
</field>
<field name="ANO" class="java.lang.String">
<fieldDescription><![CDATA[/custominfo/multiplerecord/summary/record/@ANO]]></fieldDescription>
</field>
<field name="CONTENT" class="java.lang.String">
<fieldDescription><![CDATA[/custominfo/multiplerecord/summary/record/@CONTENT]]></fieldDescription>
</field>
<field name="REMARKS" class="java.lang.String">
<fieldDescription><![CDATA[/custominfo/multiplerecord/summary/record/@REMARKS]]></fieldDescription>
</field>
<field name="SECTION" class="java.lang.String">
<fieldDescription><![CDATA[/custominfo/multiplerecord/summary/record/@SECTION]]></fieldDescription>
</field>
<field name="SRNO" class="java.lang.String">
<fieldDescription><![CDATA[/custominfo/multiplerecord/summary/record/@SRNO]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<columnHeader>
<band height="21" splitType="Stretch">
<staticText>
<reportElement x="3" y="0" width="552" height="20" uuid="8b2b2894-fc50-442c-8ab8-8e46fa55053e"/>
<textElement textAlignment="Center">
<font size="14" isBold="true" isUnderline="true"/>
</textElement>
<text><![CDATA[Summary of the report]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band splitType="Stretch"/>
<band height="22">
<textField>
<reportElement x="0" y="2" width="100" height="20" uuid="4838078b-55c8-4b87-9a86-2d193d4f63bf"/>
<textFieldExpression><![CDATA[$F{SRNO}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
示例XML:
<?xml version="1.0" encoding="UTF-8"?>
<custominfo>
<singlerecord BANK="ABC" BRANCH="XYZ" AMOUNT="Rs. 20,50,000/-" ADATE="27th February-2018" RDATE="3rd March -2018" REFNO="ABC12121" />
<multiplerecord>
<summary>
<record SECTION="1" SRNO="1" CONTENT="Test1" ANO="A" REMARKS="Test3" />
<record SECTION="1" SRNO="2" CONTENT="Test2" ANO="B" REMARKS="Test4" />
</summary>
<oberservation>
<record SECTION="2" OBSERVATION="No Observation"></record>
</oberservation>
</multiplerecord>
</custominfo>
我正在使用XML数据源;当我预览主报表时,子报表字段在主报表中显示为null,但是当我直接预览子报表时,它工作正常。
请帮助我了解为什么会发生
答案 0 :(得分:0)
字段映射应相对于数据源选择的节点,因此您在子报表中需要的是
<field name="SRNO" class="java.lang.String">
<fieldDescription><![CDATA[@SRNO]]></fieldDescription>
</field>
主报告中也有同样的情况,您应该使用@ADATE
,@AMOUNT
等作为字段映射。