json - 使用相同的 JSON 数据适配器后,子报告未显示在主报告中
问题描述
大家好,我对主报告和子报告使用相同的 JSON 数据源。子报表单独呈现并显示正确的数据,但是当我呈现主报表时,子报表没有显示。此项目使用 DataAdapter 填充报告数据。任何帮助将不胜感激。
主来源:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.12.2.final using JasperReports Library version 6.12.2-75c5e90a222ab406e416cbf590a5397028a52de3 -->
<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="Blank_A4" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="b740c94e-e1f7-4c3f-923e-277307164214">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="DataAdapterDummyJSON.xml"/>
<subDataset name="requiredDocuments" uuid="1da38f37-3954-4fc1-a49a-838d0998f903">
<queryString>
<![CDATA[]]>
</queryString>
</subDataset>
<queryString language="JSON">
<![CDATA[data]]>
</queryString>
<field name="idcNumber" class="java.lang.Long">
<property name="net.sf.jasperreports.json.field.expression" value="idcNumber"/>
<fieldDescription><![CDATA[idcNumber]]></fieldDescription>
</field>
<field name="cesco" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="cesco"/>
<fieldDescription><![CDATA[cesco]]></fieldDescription>
</field>
<field name="digitalExpirationDate" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="digitalExpirationDate"/>
<fieldDescription><![CDATA[digitalExpirationDate]]></fieldDescription>
</field>
<field name="licenseRenewalDate" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="licenseRenewalDate"/>
<fieldDescription><![CDATA[licenseRenewalDate]]></fieldDescription>
</field>
<field name="reportCreationDate" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="reportCreationDate"/>
<fieldDescription><![CDATA[reportCreationDate]]></fieldDescription>
</field>
<field name="firstName" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="firstName"/>
<fieldDescription><![CDATA[firstName]]></fieldDescription>
</field>
<field name="lastName" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="lastName"/>
<fieldDescription><![CDATA[lastName]]></fieldDescription>
</field>
<field name="realId" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="realId"/>
<fieldDescription><![CDATA[realId]]></fieldDescription>
</field>
<field name="requiredDocuments" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="requiredDocuments"/>
<fieldDescription><![CDATA[requiredDocuments]]></fieldDescription>
</field>
<field name="finesCount" class="java.lang.Long">
<property name="net.sf.jasperreports.json.field.expression" value="finesCount"/>
<fieldDescription><![CDATA[finesCount]]></fieldDescription>
</field>
<field name="finesTotal" class="java.math.BigDecimal">
<property name="net.sf.jasperreports.json.field.expression" value="finesTotal"/>
<fieldDescription><![CDATA[finesTotal]]></fieldDescription>
</field>
<field name="lateFees" class="java.math.BigDecimal">
<property name="net.sf.jasperreports.json.field.expression" value="lateFees"/>
<fieldDescription><![CDATA[lateFees]]></fieldDescription>
</field>
<field name="finesDiscount" class="java.math.BigDecimal">
<property name="net.sf.jasperreports.json.field.expression" value="finesDiscount"/>
<fieldDescription><![CDATA[finesDiscount]]></fieldDescription>
</field>
<field name="transactionReceipt" class="java.lang.Long">
<property name="net.sf.jasperreports.json.field.expression" value="transactionReceipt"/>
<fieldDescription><![CDATA[transactionReceipt]]></fieldDescription>
</field>
<field name="charges" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="charges"/>
<fieldDescription><![CDATA[charges]]></fieldDescription>
</field>
<background>
<band splitType="Stretch"/>
</background>
<title>
<band height="173" splitType="Stretch">
<image>
<reportElement x="481" y="0" width="72" height="72" uuid="230d7b00-a7b1-4e3a-98d4-d5a5437233ad">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<imageExpression><![CDATA["https://upload.wikimedia.org/wikipedia/commons/thumb/4/41/QR_Code_Example.svg/1200px-QR_Code_Example.svg.png"]]></imageExpression>
</image>
<staticText>
<reportElement x="-20" y="80" width="595" height="30" uuid="504bf28a-d83a-46cd-a3c2-ea332dea2f45"/>
<textElement textAlignment="Center" verticalAlignment="Middle">
<font fontName="SansSerif" size="18" isBold="true"/>
</textElement>
<text><![CDATA[RENOVACIÓN LICENCIA DE CONDUCIR]]></text>
</staticText>
<rectangle>
<reportElement x="-20" y="130" width="595" height="32" forecolor="#E7EAF3" backcolor="#E7EAF3" uuid="62dbd595-a135-4e3b-a57f-039a0fdd7d9e">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
</rectangle>
<staticText>
<reportElement x="185" y="130" width="50" height="32" uuid="359d3e77-b483-4d15-80e4-317748044b4b">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.x" value="px"/>
</reportElement>
<textElement verticalAlignment="Middle">
<font fontName="SansSerif" size="18" isBold="true"/>
</textElement>
<text><![CDATA[IDC#:]]></text>
</staticText>
<image>
<reportElement x="1" y="8" width="125" height="55" uuid="9a2c67f8-1838-44e0-9788-1596027bfe97">
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<imageExpression><![CDATA["/ImageAssets/Logo_CESCO_Black_300-01.png"]]></imageExpression>
</image>
<textField>
<reportElement x="240" y="130" width="174" height="32" uuid="b5ce990b-316a-43d0-b1f9-1a82096ad25c">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement verticalAlignment="Middle">
<font size="18" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{idcNumber}]]></textFieldExpression>
</textField>
</band>
</title>
<pageHeader>
<band height="81" splitType="Stretch">
<staticText>
<reportElement x="0" y="22" width="52" height="17" uuid="08447dfb-ae65-4263-85c7-23458503a2fe">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font fontName="SansSerif" size="14" isBold="false" isItalic="false"/>
</textElement>
<text><![CDATA[FECHA: ]]></text>
</staticText>
<staticText>
<reportElement x="0" y="40" width="65" height="17" uuid="94542aaf-713f-44b2-85cd-4c53914a5ac7">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font fontName="SansSerif" size="14" isBold="false"/>
</textElement>
<text><![CDATA[CESCO: ]]></text>
</staticText>
<staticText>
<reportElement x="390" y="22" width="163" height="22" uuid="44fdaa70-e5d9-4f16-89d9-40dcb7302f3b">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font fontName="SansSerif" size="14" isBold="false" isItalic="false"/>
</textElement>
<text><![CDATA[EXPIRACIÓN DIGITAL: ]]></text>
</staticText>
<staticText>
<reportElement x="390" y="39" width="100" height="30" uuid="f03e03bc-216a-474d-beaf-0767385b6a49"/>
<textElement>
<font fontName="SansSerif" size="14" isBold="true"/>
</textElement>
<text><![CDATA[03.28.2020]]></text>
</staticText>
<line>
<reportElement x="0" y="74" width="555" height="1" forecolor="#C3D0E6" backcolor="#C3D0E6" uuid="a8dc7c8b-5f54-4a51-bdae-175c0add0987">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
</line>
<textField>
<reportElement x="58" y="39" width="233" height="19" uuid="8b485199-6f49-4129-b332-7caa6e3f00a0">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{cesco}]]></textFieldExpression>
</textField>
<textField pattern="mm.dd.yyyy">
<reportElement x="57" y="21" width="156" height="19" uuid="d4f3b751-0dda-4af9-8a22-739986963bb3">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement verticalAlignment="Middle">
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[new java.util.Date()]]></textFieldExpression>
</textField>
</band>
</pageHeader>
<columnHeader>
<band height="79" splitType="Stretch">
<staticText>
<reportElement x="0" y="21" width="196" height="38" uuid="5c2e2f49-ae7c-4e8b-803f-14b6247ddcba">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement markup="html">
<font fontName="SansSerif" size="16" isBold="true" isItalic="false"/>
<paragraph lineSpacing="Fixed" lineSpacingSize="10.75"/>
</textElement>
<text><![CDATA[Hermenegildo M. Maldonado Rodríguez]]></text>
</staticText>
<staticText>
<reportElement x="226" y="22" width="110" height="19" uuid="bedd6941-9ba3-4adb-9be7-225c01088cbc">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="14" isBold="false" isItalic="false"/>
</textElement>
<text><![CDATA[CATEGORÍA:]]></text>
</staticText>
<staticText>
<reportElement x="226" y="39" width="80" height="19" uuid="55f43612-d6f1-4abc-9dc8-2f60c068cab7">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="14" isBold="false" isItalic="false"/>
</textElement>
<text><![CDATA[REAL ID:]]></text>
</staticText>
<staticText>
<reportElement x="315" y="20" width="12" height="19" uuid="f1f43459-6647-4fbe-90fb-d0ea4f67163e">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
<property name="com.jaspersoft.studio.unit.y" value="px"/>
</reportElement>
<textElement>
<font fontName="SansSerif" size="16" isBold="true"/>
</textElement>
<text><![CDATA[3]]></text>
</staticText>
<staticText>
<reportElement x="288" y="38" width="18" height="19" uuid="11b6a3a0-04c0-40be-8710-6bde05720c79">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font size="16" isBold="true"/>
</textElement>
<text><![CDATA[Sí]]></text>
</staticText>
<staticText>
<reportElement x="390" y="21" width="165" height="19" uuid="aa23217e-9700-40d9-a258-83a3909aee2e">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="14" isBold="false" isItalic="false"/>
</textElement>
<text><![CDATA[EXPIRACIÓN LICENCIA²: ]]></text>
</staticText>
<staticText>
<reportElement x="390" y="37" width="100" height="19" uuid="aa7d5495-d928-4e94-b48e-05f4fbcac1bb">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<textElement>
<font size="14" isBold="true"/>
</textElement>
<text><![CDATA[03.28.2020]]></text>
</staticText>
<line>
<reportElement x="0" y="77" width="555" height="1" forecolor="#C3D0E6" backcolor="#C3D0E6" uuid="42e5bb72-4f9a-4f83-8550-017bffcfd9b3">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
</line>
</band>
</columnHeader>
<detail>
<band height="386" splitType="Stretch">
<staticText>
<reportElement x="1" y="19" width="552" height="22" uuid="5d45b4e5-f23a-4c44-bd87-caf78a955312">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="12" isBold="false" isItalic="false"/>
</textElement>
<text><![CDATA[Este comunicado también ha sido enviado a su correo electrónico. ]]></text>
</staticText>
<staticText>
<reportElement x="1" y="54" width="552" height="22" uuid="2712b163-8d9b-4de9-bc6b-b2bc8ecb01df">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
<property name="com.jaspersoft.studio.unit.width" value="px"/>
</reportElement>
<textElement>
<font size="12" isBold="false" isItalic="false"/>
</textElement>
<text><![CDATA[Documentos necesarios para el recogido de la licencia:]]></text>
</staticText>
<frame>
<reportElement x="0" y="93" width="555" height="200" uuid="1935ef5e-f834-478a-9cc8-435f7a85418c"/>
<subreport overflowType="NoStretch">
<reportElement x="0" y="0" width="555" height="200" uuid="c23cac66-6669-48fc-b3d4-a0bea131b3f7"/>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>
<subreportExpression><![CDATA["RequiredDocuments.jasper"]]></subreportExpression>
</subreport>
</frame>
</band>
</detail>
<columnFooter>
<band height="48" splitType="Stretch">
<staticText>
<reportElement x="-2" y="-51" width="489" height="30" uuid="e7d65538-6c09-441b-b755-223d083d4b20"/>
<textElement>
<font size="12"/>
</textElement>
<text><![CDATA[De no tener algunos de estos documentos favor de seguir las instrucciones adjuntas. ]]></text>
</staticText>
</band>
</columnFooter>
</jasperReport>
在子报告的来源下方:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.12.2.final using JasperReports Library version 6.12.2-75c5e90a222ab406e416cbf590a5397028a52de3 -->
<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="RequiredDocuments" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="4ede3a66-e567-4965-97b6-db3c2f081036">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="DataAdapterDummyJSON.xml"/>
<queryString language="json">
<![CDATA[data.requiredDocuments]]>
</queryString>
<field name="documentNumber" class="java.lang.Integer">
<property name="net.sf.jasperreports.json.field.expression" value="documentNumber"/>
<fieldDescription><![CDATA[documentNumber]]></fieldDescription>
</field>
<field name="title" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="title"/>
<fieldDescription><![CDATA[title]]></fieldDescription>
</field>
<field name="instruction" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="instruction"/>
<fieldDescription><![CDATA[instruction]]></fieldDescription>
</field>
<group name="title">
<groupExpression><![CDATA[$F{title}]]></groupExpression>
</group>
<group name="documentNumber">
<groupExpression><![CDATA[$F{documentNumber}]]></groupExpression>
</group>
<background>
<band splitType="Stretch"/>
</background>
<detail>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="0" y="0" width="280" height="20" uuid="93e63c57-c041-43ce-9a1c-2607366a46c0"/>
<textElement>
<font size="14" isBold="true"/>
</textElement>
<textFieldExpression><![CDATA[$F{documentNumber} + ". " + $F{title}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
这是我用于报告的 JSON 文件:
{
"data": {
"idcNumber": 1234567890123,
"cesco": "Sagrado Corazón",
"digitalExpirationDate": "2020-04-07 09:27:45",
"licenseRenewalDate": "2020-04-07 09:27:45",
"reportCreationDate": "2020-04-07 09:27:45",
"firstName": "Hermelegildo M.",
"lastName": "Maldonado Rodríguez",
"realId": false,
"requiredDocuments": [
{
"documentNumber": 1,
"title": "Este Documento Impreso o Digital",
"instruction": "Lorem Ipsum es simplemente el texto de relleno de las imprentas y archivos de texto. Lorem Ipsum ha sido el texto de relleno estándar de las industrias desde el año 1500, cuando un impresor (N. del T. persona que se dedica a la imprenta) desconocido usó una galería de textos y los mezcló de tal manera que logró hacer un libro de textos especimen. No sólo sobrevivió 500 años, sino que tambien ingresó como texto de relleno en documentos electrónicos, quedando esencialmente igual al original. Fue popularizado en los 60s con la creación de las hojas \"Letraset\", las cuales contenian pasajes de Lorem Ipsum, y más recientemente con software de autoedición, como por ejemplo Aldus PageMaker, el cual incluye versiones de Lorem Ipsum."
},
{
"documentNumber": 2,
"title": "Licencia Actual",
"instruction": "Lorem Ipsum es simplemente el texto de relleno de las imprentas y archivos de texto. Lorem Ipsum ha sido el texto de relleno estándar de las industrias desde el año 1500, cuando un impresor (N. del T. persona que se dedica a la imprenta) desconocido usó una galería de textos y los mezcló de tal manera que logró hacer un libro de textos especimen. No sólo sobrevivió 500 años, sino que tambien ingresó como texto de relleno en documentos electrónicos, quedando esencialmente igual al original. Fue popularizado en los 60s con la creación de las hojas \"Letraset\", las cuales contenian pasajes de Lorem Ipsum, y más recientemente con software de autoedición, como por ejemplo Aldus PageMaker, el cual incluye versiones de Lorem Ipsum."
},{
"documentNumber": 3,
"title": "Seguro Social / Pasaporte",
"instruction": "Lorem Ipsum es simplemente el texto de relleno de las imprentas y archivos de texto. Lorem Ipsum ha sido el texto de relleno estándar de las industrias desde el año 1500, cuando un impresor (N. del T. persona que se dedica a la imprenta) desconocido usó una galería de textos y los mezcló de tal manera que logró hacer un libro de textos especimen. No sólo sobrevivió 500 años, sino que tambien ingresó como texto de relleno en documentos electrónicos, quedando esencialmente igual al original. Fue popularizado en los 60s con la creación de las hojas \"Letraset\", las cuales contenian pasajes de Lorem Ipsum, y más recientemente con software de autoedición, como por ejemplo Aldus PageMaker, el cual incluye versiones de Lorem Ipsum."
},{
"documentNumber": 4,
"title": "Recibo Agua, Luz, etc.",
"instruction": "Lorem Ipsum es simplemente el texto de relleno de las imprentas y archivos de texto. Lorem Ipsum ha sido el texto de relleno estándar de las industrias desde el año 1500, cuando un impresor (N. del T. persona que se dedica a la imprenta) desconocido usó una galería de textos y los mezcló de tal manera que logró hacer un libro de textos especimen. No sólo sobrevivió 500 años, sino que tambien ingresó como texto de relleno en documentos electrónicos, quedando esencialmente igual al original. Fue popularizado en los 60s con la creación de las hojas \"Letraset\", las cuales contenian pasajes de Lorem Ipsum, y más recientemente con software de autoedición, como por ejemplo Aldus PageMaker, el cual incluye versiones de Lorem Ipsum."
},{
"documentNumber": 5,
"title": "Foto y Firma Digitalizada",
"instruction": "Lorem Ipsum es simplemente el texto de relleno de las imprentas y archivos de texto. Lorem Ipsum ha sido el texto de relleno estándar de las industrias desde el año 1500, cuando un impresor (N. del T. persona que se dedica a la imprenta) desconocido usó una galería de textos y los mezcló de tal manera que logró hacer un libro de textos especimen. No sólo sobrevivió 500 años, sino que tambien ingresó como texto de relleno en documentos electrónicos, quedando esencialmente igual al original. Fue popularizado en los 60s con la creación de las hojas \"Letraset\", las cuales contenian pasajes de Lorem Ipsum, y más recientemente con software de autoedición, como por ejemplo Aldus PageMaker, el cual incluye versiones de Lorem Ipsum."
}
],
"finesCount": 25,
"finesTotal": 12000.00,
"lateFees": 60.00,
"finesDiscount": 60.00,
"transactionReceipt": 120459593030,
"charges": [
{
"chargeName": "Renovación Digital",
"chargeAmount": 11.00
},
{
"chargeName": "Renovación",
"chargeAmount": 11.00
}
]
}
}
解决方案
您的子报表需要正确连接到数据源,因为$P{REPORT_CONNECTION}
它null
适用于任何基于非 JDBC 的连接:
<subreport overflowType="NoStretch">
<reportElement x="0" y="0" width="555" height="200" uuid="c23cac66-6669-48fc-b3d4-a0bea131b3f7"/>
<dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("requiredDocuments")]]></dataSourceExpression>
<subreportExpression><![CDATA["RequiredDocuments.jasper"]]></subreportExpression>
</subreport>
推荐阅读
- go - Assert interface to slice of struct
- openssl - Adding multiple DNS to CSR with Openssl via command prompt
- r - How can I change the factors to numeric variables or otherwise deal with this error I'm getting in my linear regression
- python - MDSpinner from kivymd doesn't work for me as expected
- php - 查询后如何知道我的变量是否为空(或 null) - laravel
- python - pygame 精灵运动
- oracle-cloud-infrastructure - Resource ownership of GetObjectResponse.InputStream
- c# - 当你拖放 gui 冻结
- json - 使用与 ImportJSON 相邻的单元格会引发错误:数组结果未展开,因为它会覆盖数据
- swift - Apple Watch 并发症列表中这些图标的名称是什么?我在哪里可以访问它们?