我将从HTTP请求中加载这个嵌套的JSON,并将其解析为带有多个子报表的报表,以便显示所有数据。在JAVA中,当我使用包含此结构的json文件时,一切都工作得很好,但是,当试图从JAVA填充它时,得到警告,而没有一个子报表获得数据:
PM net.sf.jasperreports.engine.query.AbstractJsonQueryExecuter createDatasource
WARNING: No JSON source was provided.
我有这样的嵌套JSON:
"receiptId":"O-6FF6640FF1624523B6640FF162E523AF",
"ico":"35838949",
"cashRegisterCode":"88820202626840039",
"issueDate":"02.07.2022 20:06:57",
"createDate":"02.07.2022 20:06:57",
"customerId":null,
"dic":"2020262684",
"icDph":"SK2020262684",
"invoiceNumber":null,
"okp":"6822E8DC-E997DD0D-DD384721-E98AF90A-9C3DCA8C",
"paragon":false,
"paragonNumber":null,
"pkp":"Y1yRcaaLrgMYCXwjJ1LlNwHyZbkZFlpT+TTM+6K+8poUolICKkPpR+6hhpqNYjWapzA+AAIA/AIdGEaf5xKxvRzqrTImQF0ifgV320C1NawGSkiWFcd4H4bEDGOncRcEWk7mx08W0sGWQ7KACIuVFMcIbiG+ttHdUATsLyOciddD6D++VB0SoN42X8RRFAbAQ/qewUzwN/jhi9JRCl2vWzK5iP2d7VFiEyaQ3kZ3uk37xfTQu9Cs2co28tWJas+p3PCL9Y5/YwLHCW5+Y9F6co/QLQRR0YN7CP7yksninoWzF+urJb03WZa27gGjXtprebfozUXkLc6QdRns6zGIjQ==",
"receiptNumber":752,
"type":"PD",
"taxBaseBasic":10.9800,
"taxBaseReduced":0.0000,
"totalPrice":13.1800,
"freeTaxAmount":0.0000,
"vatAmountBasic":2.2000,
"vatAmountReduced":0.0000,
"vatRateBasic":20.0000,
"vatRateReduced":10.0000,
"items":[
{"name":"LUKAS AKRYL FARBA \"T",
"itemType":"K",
"quantity":1.0000,
"vatRate":20.00,
"price":6.59},
{"name":"LUKAS AKRYL FARBA ",
"itemType":"K","quantity":1.0000,
"vatRate":20.00,
"price":6.59}
],
"organization":{
"buildingNumber":null,
"country":"Slovensko",
"dic":"2020262684",
"icDph":"SK2020262684",
"ico":"35838949",
"municipality":"Bratislava - mestská časť Ružinov",
"name":"HORNBACH - Baumarkt SK spol. s r.o.",
"postalCode":"82104",
"propertyRegistrationNumber":"9",
"streetName":"Galvaniho",
"vatPayer":true
},
"unit":{
"cashRegisterCode":"88820202626840039",
"buildingNumber":null,
"country":"Slovensko",
"municipality":"Košice",
"postalCode":"04011",
"propertyRegistrationNumber":"22",
"streetName":"Moldavská cesta",
"name":null,
"unitType":"STANDARD"
},
"exemption":false
}
总报告:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.19.1.final using JasperReports Library version 6.19.1-867c00bf88cd4d784d404379d6c05e1b419e8a4c -->
<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="BlocekMaster" pageWidth="226" pageHeight="842" columnWidth="186" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="bf498b99-386e-42ef-99c8-2045acf3acb6">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="JSON.jrdax"/>
<property name="com.jaspersoft.studio.unit.pageWidth" value="cm"/>
<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>
<parameter name="SUBREPORT_DIR" class="java.lang.String" isForPrompting="false"/>
<queryString language="json">
<![CDATA[receipt]]>
</queryString>
<field name="freeTaxAmount" class="java.lang.Integer">
<property name="net.sf.jasperreports.json.field.expression" value="freeTaxAmount"/>
<fieldDescription><![CDATA[freeTaxAmount]]></fieldDescription>
</field>
<field name="totalPrice" class="java.math.BigDecimal">
<property name="net.sf.jasperreports.json.field.expression" value="totalPrice"/>
<fieldDescription><![CDATA[totalPrice]]></fieldDescription>
</field>
<field name="vatRateReduced" class="java.lang.Integer">
<property name="net.sf.jasperreports.json.field.expression" value="vatRateReduced"/>
<fieldDescription><![CDATA[vatRateReduced]]></fieldDescription>
</field>
<field name="exemption" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="exemption"/>
<fieldDescription><![CDATA[exemption]]></fieldDescription>
</field>
<field name="type" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="type"/>
<fieldDescription><![CDATA[type]]></fieldDescription>
</field>
<field name="vatRateBasic" class="java.lang.Integer">
<property name="net.sf.jasperreports.json.field.expression" value="vatRateBasic"/>
<fieldDescription><![CDATA[vatRateBasic]]></fieldDescription>
</field>
<field name="paragon" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="paragon"/>
<fieldDescription><![CDATA[paragon]]></fieldDescription>
</field>
<field name="taxBaseBasic" class="java.math.BigDecimal">
<property name="net.sf.jasperreports.json.field.expression" value="taxBaseBasic"/>
<fieldDescription><![CDATA[taxBaseBasic]]></fieldDescription>
</field>
<field name="ico" class="java.lang.Integer">
<property name="net.sf.jasperreports.json.field.expression" value="ico"/>
<fieldDescription><![CDATA[ico]]></fieldDescription>
</field>
<field name="pkp" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="pkp"/>
<fieldDescription><![CDATA[pkp]]></fieldDescription>
</field>
<field name="okp" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="okp"/>
<fieldDescription><![CDATA[okp]]></fieldDescription>
</field>
<field name="icDph" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="icDph"/>
<fieldDescription><![CDATA[icDph]]></fieldDescription>
</field>
<field name="customerId" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="customerId"/>
<fieldDescription><![CDATA[customerId]]></fieldDescription>
</field>
<field name="invoiceNumber" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="invoiceNumber"/>
<fieldDescription><![CDATA[invoiceNumber]]></fieldDescription>
</field>
<field name="taxBaseReduced" class="java.lang.Integer">
<property name="net.sf.jasperreports.json.field.expression" value="taxBaseReduced"/>
<fieldDescription><![CDATA[taxBaseReduced]]></fieldDescription>
</field>
<field name="issueDate" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="issueDate"/>
<fieldDescription><![CDATA[issueDate]]></fieldDescription>
</field>
<field name="vatAmountReduced" class="java.lang.Integer">
<property name="net.sf.jasperreports.json.field.expression" value="vatAmountReduced"/>
<fieldDescription><![CDATA[vatAmountReduced]]></fieldDescription>
</field>
<field name="receiptId" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="receiptId"/>
<fieldDescription><![CDATA[receiptId]]></fieldDescription>
</field>
<field name="receiptNumber" class="java.lang.Integer">
<property name="net.sf.jasperreports.json.field.expression" value="receiptNumber"/>
<fieldDescription><![CDATA[receiptNumber]]></fieldDescription>
</field>
<field name="createDate" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="createDate"/>
<fieldDescription><![CDATA[createDate]]></fieldDescription>
</field>
<field name="cashRegisterCode" class="java.lang.Long">
<property name="net.sf.jasperreports.json.field.expression" value="cashRegisterCode"/>
<fieldDescription><![CDATA[cashRegisterCode]]></fieldDescription>
</field>
<field name="paragonNumber" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="paragonNumber"/>
<fieldDescription><![CDATA[paragonNumber]]></fieldDescription>
</field>
<field name="vatAmountBasic" class="java.math.BigDecimal">
<property name="net.sf.jasperreports.json.field.expression" value="vatAmountBasic"/>
<fieldDescription><![CDATA[vatAmountBasic]]></fieldDescription>
</field>
<field name="dic" class="java.lang.Integer">
<property name="net.sf.jasperreports.json.field.expression" value="dic"/>
<fieldDescription><![CDATA[dic]]></fieldDescription>
</field>
<field name="itemsName" class="java.lang.Object">
<property name="net.sf.jasperreports.json.field.expression" value="items.name"/>
<fieldDescription><![CDATA[itemsName]]></fieldDescription>
</field>
<title>
<band height="37" splitType="Stretch"/>
</title>
<pageHeader>
<band height="141" splitType="Stretch">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<subreport>
<reportElement isPrintRepeatedValues="false" x="0" y="0" width="186" height="60" uuid="067bb739-cd7f-460b-b766-20bdfb569665"/>
<parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression>
<subreportExpression><![CDATA["c:\\Users\\Rastislav\\JaspersoftWorkspace\\VydavkovyDoklad\\BlocekOrganization.jasper"]]></subreportExpression>
</subreport>
<subreport>
<reportElement x="0" y="60" width="185" height="20" uuid="36001917-250a-4b58-8399-8b9b380b2808">
<property name="com.jaspersoft.studio.unit.height" value="px"/>
</reportElement>
<parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression>
<subreportExpression><![CDATA["c:\\Users\\Rastislav\\JaspersoftWorkspace\\VydavkovyDoklad\\BlocekUnit.jasper"]]></subreportExpression>
</subreport>
<textField>
<reportElement x="20" y="80" width="60" height="20" uuid="e33c8cdf-1fea-488c-9775-42d5547fd914"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{dic}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="20" y="100" width="60" height="20" uuid="da649d7f-a1d7-45bb-a9a9-f4e376be35dc"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{ico}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="120" y="80" width="66" height="20" uuid="8010e7c9-154d-487b-be86-e67f3e078e9b"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{icDph}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="0" y="80" width="20" height="20" uuid="05f35676-3cba-45d3-a422-7c892f5813de"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[DIč:]]></text>
</staticText>
<staticText>
<reportElement x="0" y="100" width="20" height="20" uuid="3eee3d1d-52e0-4499-ad6c-c5e9fb919d60"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Ičo:]]></text>
</staticText>
<staticText>
<reportElement x="80" y="80" width="40" height="20" uuid="04c8959f-5718-4c71-bb96-94728217bdab"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[IČ DPH:]]></text>
</staticText>
<textField>
<reportElement x="0" y="120" width="100" height="20" uuid="62f10218-b278-4832-b6cc-f1e3169524ad"/>
<box>
<topPen lineWidth="1.0" lineStyle="Dashed"/>
<bottomPen lineWidth="1.0" lineStyle="Dashed"/>
</box>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{createDate}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="150" y="120" width="36" height="20" uuid="55bcebe0-e88e-4101-86ec-cd587fba0db6"/>
<box>
<topPen lineWidth="1.0" lineStyle="Dashed"/>
<bottomPen lineWidth="1.0" lineStyle="Dashed"/>
</box>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{receiptNumber}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="100" y="120" width="50" height="20" uuid="2c02b2de-6c26-4deb-9e5d-3c3868bc9c77"/>
<box>
<topPen lineWidth="1.0" lineStyle="Dashed"/>
<bottomPen lineWidth="1.0" lineStyle="Dashed"/>
</box>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<text><![CDATA[č. bloku:]]></text>
</staticText>
</band>
</pageHeader>
<detail>
<band height="90" splitType="Stretch">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.HorizontalRowLayout"/>
<subreport>
<reportElement isPrintRepeatedValues="false" x="0" y="0" width="186" height="90" uuid="66bb5110-f039-4173-986e-1bd0289bc122"/>
<parametersMapExpression><![CDATA[$P{REPORT_PARAMETERS_MAP}]]></parametersMapExpression>
<subreportExpression><![CDATA["c:\\Users\\Rastislav\\JaspersoftWorkspace\\VydavkovyDoklad\\BlocekItems.jasper"]]></subreportExpression>
</subreport>
</band>
</detail>
<summary>
<band height="269" splitType="Stretch">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<staticText>
<reportElement x="0" y="0" width="93" height="20" uuid="0c8368f5-5fb4-40ad-b0e0-f35c99b77891"/>
<box>
<topPen lineWidth="1.0" lineStyle="Dashed"/>
<bottomPen lineWidth="1.0" lineStyle="Dashed"/>
</box>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Celková cena]]></text>
</staticText>
<textField>
<reportElement x="93" y="0" width="93" height="20" uuid="83d9395f-3daf-48c0-a917-123839303cae"/>
<box>
<topPen lineWidth="1.0" lineStyle="Dashed"/>
<bottomPen lineWidth="1.0" lineStyle="Dashed"/>
</box>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{totalPrice}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="50" y="40" width="70" height="20" isRemoveLineWhenBlank="true" uuid="dd57123a-272f-4e1c-b95a-34a0e1792a68">
<property name="com.jaspersoft.studio.unit.rightIndent" value="px"/>
</reportElement>
<textElement textAlignment="Right">
<paragraph rightIndent="3"/>
</textElement>
<textFieldExpression><![CDATA[$F{taxBaseBasic}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="50" y="60" width="70" height="20" isRemoveLineWhenBlank="true" uuid="b62217da-ab63-4b70-a835-85a38816d9cf">
<property name="com.jaspersoft.studio.unit.rightIndent" value="px"/>
</reportElement>
<textElement textAlignment="Right">
<paragraph rightIndent="3"/>
</textElement>
<textFieldExpression><![CDATA[$F{taxBaseReduced}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="120" y="40" width="66" height="20" isRemoveLineWhenBlank="true" uuid="15925546-74b9-4b8a-a97f-c5f09a46297e">
<property name="com.jaspersoft.studio.unit.rightIndent" value="px"/>
</reportElement>
<textElement textAlignment="Right">
<paragraph rightIndent="3"/>
</textElement>
<textFieldExpression><![CDATA[$F{vatAmountBasic}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="120" y="60" width="66" height="20" isRemoveLineWhenBlank="true" uuid="4cbd792a-b549-490b-9d5d-ee66420008da">
<property name="com.jaspersoft.studio.unit.rightIndent" value="px"/>
</reportElement>
<textElement textAlignment="Right">
<paragraph rightIndent="3"/>
</textElement>
<textFieldExpression><![CDATA[$F{vatAmountReduced}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="50" y="80" width="70" height="20" isRemoveLineWhenBlank="true" uuid="1fcf6b04-e892-40b4-80d0-f96a75f7da6b">
<property name="com.jaspersoft.studio.unit.rightIndent" value="px"/>
</reportElement>
<textElement textAlignment="Right">
<paragraph rightIndent="3"/>
</textElement>
<textFieldExpression><![CDATA[$F{freeTaxAmount}]]></textFieldExpression>
</textField>
<staticText>
<reportElement x="0" y="20" width="50" height="20" uuid="da90ee1d-be04-4c35-8b45-856e86efaf12"/>
<textElement verticalAlignment="Middle"/>
<text><![CDATA[Sadzba:]]></text>
</staticText>
<staticText>
<reportElement x="50" y="20" width="70" height="20" uuid="2a7525e5-dd4a-425e-ae79-0946c31bf7e6"/>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<text><![CDATA[Základ:]]></text>
</staticText>
<staticText>
<reportElement x="120" y="20" width="66" height="20" uuid="68c4120c-5e31-43c3-9419-4c60c1e92454"/>
<textElement textAlignment="Right" verticalAlignment="Middle"/>
<text><![CDATA[DPH:]]></text>
</staticText>
<staticText>
<reportElement x="0" y="40" width="50" height="20" uuid="00ac1cc4-bdc8-4bd1-9ace-214fed4efe13">
<property name="com.jaspersoft.studio.unit.leftIndent" value="px"/>
</reportElement>
<textElement textAlignment="Left">
<paragraph leftIndent="3"/>
</textElement>
<text><![CDATA[20%]]></text>
</staticText>
<staticText>
<reportElement x="0" y="60" width="50" height="20" uuid="091cec9e-61e3-4655-b648-2aadd4faf2d8"/>
<textElement textAlignment="Left">
<paragraph leftIndent="3"/>
</textElement>
<text><![CDATA[10%]]></text>
</staticText>
<staticText>
<reportElement x="0" y="80" width="50" height="20" uuid="269fc2fa-824c-43e1-9b3e-283e349cfea5"/>
<textElement textAlignment="Left">
<paragraph leftIndent="3"/>
</textElement>
<text><![CDATA[ 0%]]></text>
</staticText>
<textField textAdjust="StretchHeight">
<reportElement x="30" y="140" width="156" height="28" uuid="d2abcbd6-4886-40e0-aaf1-d1f6084fcbac"/>
<textElement verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{receiptId}]]></textFieldExpression>
</textField>
<textField textAdjust="StretchHeight">
<reportElement x="30" y="108" width="156" height="32" uuid="2cbffbba-78fc-4a78-9063-0d4502c25599">
<property name="com.jaspersoft.studio.unit.spacingBefore" value="px"/>
</reportElement>
<box>
<topPen lineWidth="1.0" lineStyle="Dashed"/>
</box>
<textElement verticalAlignment="Top">
<paragraph spacingBefore="3"/>
</textElement>
<textFieldExpression><![CDATA[$F{okp}]]></textFieldExpression>
</textField>
<componentElement>
<reportElement x="0" y="168" width="186" height="100" uuid="74c4254c-bb56-45c2-9d38-86d6efca9929"/>
<jr:QRCode xmlns:jr="http://jasperreports.sourceforge.net/jasperreports/components" xsi:schemaLocation="http://jasperreports.sourceforge.net/jasperreports/components http://jasperreports.sourceforge.net/xsd/components.xsd">
<jr:codeExpression><![CDATA[$F{receiptId}]]></jr:codeExpression>
</jr:QRCode>
</componentElement>
<staticText>
<reportElement x="0" y="108" width="30" height="31" uuid="d721c096-8a9c-411c-b50a-2fb0fcb61389">
<property name="com.jaspersoft.studio.unit.spacingBefore" value="px"/>
</reportElement>
<box>
<topPen lineWidth="1.0" lineStyle="Dashed"/>
</box>
<textElement verticalAlignment="Top">
<paragraph spacingBefore="3"/>
</textElement>
<text><![CDATA[OKP:]]></text>
</staticText>
<staticText>
<reportElement x="0" y="140" width="30" height="28" uuid="2485d022-d78d-4ba9-8106-e23fca5b4d0a"/>
<text><![CDATA[UID:]]></text>
</staticText>
</band>
</summary>
</jasperReport>
其中一份分报告:
<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.19.1.final using JasperReports Library version 6.19.1-867c00bf88cd4d784d404379d6c05e1b419e8a4c -->
<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="Blocekorganization" pageWidth="186" pageHeight="70" columnWidth="186" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="3e3bdb08-1685-44c2-a19f-480aef430af4">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="JSON.jrdax"/>
<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"/>
<queryString language="json">
<![CDATA[receipt.organization]]>
</queryString>
<field name="country" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="country"/>
<fieldDescription><![CDATA[country]]></fieldDescription>
</field>
<field name="streetName" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="streetName"/>
<fieldDescription><![CDATA[streetName]]></fieldDescription>
</field>
<field name="vatPayer" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="vatPayer"/>
<fieldDescription><![CDATA[vatPayer]]></fieldDescription>
</field>
<field name="postalCode" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="postalCode"/>
<fieldDescription><![CDATA[postalCode]]></fieldDescription>
</field>
<field name="municipality" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="municipality"/>
<fieldDescription><![CDATA[municipality]]></fieldDescription>
</field>
<field name="name" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="name"/>
<fieldDescription><![CDATA[name]]></fieldDescription>
</field>
<field name="buildingNumber" class="java.lang.String">
<property name="net.sf.jasperreports.json.field.expression" value="buildingNumber"/>
<fieldDescription><![CDATA[buildingNumber]]></fieldDescription>
</field>
<field name="propertyRegistrationNumber" class="java.lang.Integer">
<property name="net.sf.jasperreports.json.field.expression" value="propertyRegistrationNumber"/>
<fieldDescription><![CDATA[propertyRegistrationNumber]]></fieldDescription>
</field>
<detail>
<band height="60" splitType="Stretch">
<property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
<textField>
<reportElement x="0" y="0" width="186" height="20" uuid="ee1bf49e-9d9a-486e-bfa3-ed01a24f4b47"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="20" width="100" height="20" uuid="961b4d56-62ab-4031-a1db-8d689748a60c">
<property name="com.jaspersoft.studio.unit.rightIndent" value="px"/>
</reportElement>
<textElement textAlignment="Right" verticalAlignment="Middle" markup="none">
<paragraph rightIndent="15"/>
</textElement>
<textFieldExpression><![CDATA[$F{streetName}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="100" y="20" width="20" height="20" uuid="90e90ff6-7c46-4ef8-bd68-6772f58f3f5e"/>
<textElement textAlignment="Left" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{propertyRegistrationNumber}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="120" y="20" width="35" height="20" uuid="3a4c0f1f-c9da-48de-9b42-ffa0921bc418"/>
<textElement textAlignment="Left" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{postalCode}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="0" y="40" width="186" height="20" uuid="fa8f7ef7-5a1c-4907-98fa-a232f4dccf86"/>
<textElement textAlignment="Center" verticalAlignment="Middle"/>
<textFieldExpression><![CDATA[$F{municipality}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>
java:
try {
/* Output file location to create report in pdf form */
String outputFile = "d:\\JAVA PROGRAMOVANIE\\0 Godis RR\\main\\GodisMaven\\target\\reports\\" + "JasperReportExample.pdf";
/* Convert List to JRBeanCollectionDataSource */
InputStream stream = new ByteArrayInputStream(myObject1.getJSONObject("receipt").toString().getBytes("UTF-8"));
JRDataSource jsonDataSource = new JsonDataSource(stream);
JasperDesign jasperDesign = JRXmlLoader.load(new File("c:\\Users\\Rastislav\\JaspersoftWorkspace\\VydavkovyDoklad\\BlocekMaster.jrxml"));
/*compiling jrxml with help of JasperReport class*/
JasperReport jasperReport = JasperCompileManager.compileReport(jasperDesign);
/* Using jasperReport object to generate PDF */
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, null, jsonDataSource);
/*call jasper engine to display report in jasperviewer window*/
JasperViewer.viewReport(jasperPrint);
/* outputStream to create PDF */
OutputStream outputStream = new FileOutputStream(new File(outputFile));
/* Write content to PDF file */
JasperExportManager.exportReportToPdfStream(jasperPrint, outputStream);
outputStream.close();
System.out.println("File Generated");
} catch (JRException | FileNotFoundException ex) {
Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
} catch (UnsupportedEncodingException ex) {
Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
} catch (IOException ex) {
Logger.getLogger(Menu.class.getName()).log(Level.SEVERE, null, ex);
}
任何帮助都将被认可。
发布于 2022-07-28 04:59:32
与其创建和传递JsonDataSource
,不如将JSON数据流直接传递给json
查询执行器(通过<queryString language="json">
在报表中使用):
Map<String, Object> parameters = new HashMap<>();
parameters.put(JsonQueryExecuterFactory.JSON_INPUT_STREAM, stream);
JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport, parameters);
https://stackoverflow.com/questions/73143105
复制相似问题