我在Jaspersoft Studio上有两个单页报表,我需要第二个报表作为第一个的子报表。第二个报告作为子报告位于第一个报告的“摘要”区域中,但是,当我生成第一个报告时,仅会生成一页,而第二个报告不会出现。当单独生成第二个报告时,它的生成效果很好,但是作为子报告却没有出现。
第一个像素为595 x 1200像素(我将其高度扩展到此1200像素值,因为尝试生成我认为是“理想”尺寸的报告时发生错误,即595 x 300像素,大概是因为第二份报告不适合第一份报告。
第二个报告具有842 x 595像素(标准A4横向)。
PS::我在“摘要”的子报表之前添加了一个 Break (分页符)组件,它开始生成两个页面,但这种方式不能满足要求:第二个为空。
第一份和第二份报告的来源如下:
CustomerData.jrxml
<?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="CustomerData" pageWidth="595" pageHeight="1200" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="bd4d8470-7810-4186-97d6-d71f820d6812">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="Customer Info Data Adapter "/>
<field name="birthday" class="java.time.LocalDate">
<fieldDescription><![CDATA[birthday]]></fieldDescription>
</field>
<field name="observacao" class="java.lang.String">
<fieldDescription><![CDATA[observacao]]></fieldDescription>
</field>
<field name="orderNumber" class="java.lang.Integer">
<fieldDescription><![CDATA[orderNumber]]></fieldDescription>
</field>
<field name="phone" class="java.lang.String">
<fieldDescription><![CDATA[phone]]></fieldDescription>
</field>
<field name="name" class="java.lang.String">
<fieldDescription><![CDATA[name]]></fieldDescription>
</field>
<field name="email" class="java.lang.String">
<fieldDescription><![CDATA[email]]></fieldDescription>
</field>
<columnHeader>
<band height="30" splitType="Stretch">
<staticText>
<reportElement x="483" y="0" width="49" height="30" uuid="1e51bb02-fa8b-48bd-a58d-f16139a04940"/>
<textElement textAlignment="Center"/>
<text><![CDATA[Email]]></text>
</staticText>
<staticText>
<reportElement x="420" y="0" width="60" height="30" uuid="ff6474e7-7410-42bb-bd20-d2d36433a667"/>
<textElement textAlignment="Center"/>
<text><![CDATA[Aniversário]]></text>
</staticText>
<staticText>
<reportElement x="360" y="0" width="60" height="30" uuid="99bf0d76-5e6b-4b1a-b31f-a4a4b772b91a"/>
<textElement textAlignment="Center"/>
<text><![CDATA[Nome]]></text>
</staticText>
<staticText>
<reportElement x="310" y="0" width="50" height="30" uuid="a274c422-f123-42e0-b982-be9fc8cfa1f8"/>
<textElement textAlignment="Center"/>
<text><![CDATA[Número do pedido]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="34" splitType="Stretch">
<textField>
<reportElement x="310" y="0" width="50" height="30" uuid="c2580e15-8711-4f3c-a0f8-91352165bdee"/>
<textFieldExpression><![CDATA[$F{orderNumber}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="360" y="0" width="60" height="30" uuid="ad811b37-da69-4624-9dbf-c0eeb4fd7e8b"/>
<textFieldExpression><![CDATA[$F{name}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="420" y="0" width="60" height="30" uuid="0e2dcac2-0359-474d-807e-a08c135d3758"/>
<textFieldExpression><![CDATA[$F{birthday}.format( java.time.format.DateTimeFormatter.ofPattern("dd/MM/yyyy") )]]></textFieldExpression>
</textField>
<textField>
<reportElement x="480" y="0" width="52" height="30" uuid="285f9ede-e240-483c-8709-3596d8e25b14"/>
<textFieldExpression><![CDATA[$F{email}]]></textFieldExpression>
</textField>
</band>
</detail>
<pageFooter>
<band height="20" splitType="Stretch">
<textField>
<reportElement x="440" y="0" width="60" height="18" uuid="616ea806-33dd-4e95-9881-7ec4bc81ef99"/>
<textElement textAlignment="Right"/>
<textFieldExpression><![CDATA["Página " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
<textField evaluationTime="Report">
<reportElement x="500" y="0" width="53" height="18" uuid="41fdb36f-d901-4335-b402-58d51bd62a5d"/>
<textFieldExpression><![CDATA[" de " + $V{PAGE_NUMBER}]]></textFieldExpression>
</textField>
</band>
</pageFooter>
<summary>
<band height="215" splitType="Stretch">
<subreport>
<reportElement x="0" y="10" width="553" height="200" uuid="7cfb9c5c-358e-46e5-9f62-385d1d1c974f"/>
<connectionExpression><![CDATA[$P{REPORT_CONNECTION} ]]></connectionExpression>
<subreportExpression><![CDATA["CustomerAddresses.jasper"]]></subreportExpression>
</subreport>
</band>
</summary>
</jasperReport>
CustomerAddresses.jrxml
<?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="CustomerAddresses" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="802" leftMargin="20" rightMargin="20" topMargin="20" bottomMargin="20" uuid="c3c27bb5-2480-413f-87af-06a106a9b242">
<property name="com.jaspersoft.studio.data.defaultdataadapter" value="New Data Adapter "/>
<field name="number" class="java.lang.String">
<fieldDescription><![CDATA[number]]></fieldDescription>
</field>
<field name="city" class="java.lang.String">
<fieldDescription><![CDATA[city]]></fieldDescription>
</field>
<field name="bairro" class="java.lang.String">
<fieldDescription><![CDATA[bairro]]></fieldDescription>
</field>
<field name="street" class="java.lang.String">
<fieldDescription><![CDATA[street]]></fieldDescription>
</field>
<field name="complement" class="java.lang.String">
<fieldDescription><![CDATA[complement]]></fieldDescription>
</field>
<field name="title" class="java.lang.String">
<fieldDescription><![CDATA[title]]></fieldDescription>
</field>
<field name="cep" class="java.lang.String">
<fieldDescription><![CDATA[cep]]></fieldDescription>
</field>
<field name="referencePoint" class="java.lang.String">
<fieldDescription><![CDATA[referencePoint]]></fieldDescription>
</field>
<columnHeader>
<band height="62" splitType="Stretch">
<staticText>
<reportElement x="20" y="20" width="100" height="30" uuid="e0013f45-d0ed-4c51-9aca-9de907da1d9c"/>
<textElement textAlignment="Center"/>
<text><![CDATA[Título]]></text>
</staticText>
<staticText>
<reportElement x="130" y="20" width="100" height="30" uuid="92a0e07c-b9ee-4c75-a048-689a85bf9457"/>
<textElement textAlignment="Center"/>
<text><![CDATA[Rua]]></text>
</staticText>
<staticText>
<reportElement x="240" y="20" width="100" height="30" uuid="5f1985ff-0847-4e69-abbe-e5df3bf52ccb"/>
<textElement textAlignment="Center"/>
<text><![CDATA[Cidade]]></text>
</staticText>
</band>
</columnHeader>
<detail>
<band height="60" splitType="Stretch">
<textField>
<reportElement x="20" y="30" width="100" height="30" uuid="cb4f331a-5dd3-432a-808e-161d3e0cad3d"/>
<textFieldExpression><![CDATA[$F{title}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="130" y="30" width="100" height="30" uuid="f541ed9a-0974-412b-9991-e36f9d499af8"/>
<textFieldExpression><![CDATA[$F{street}]]></textFieldExpression>
</textField>
<textField>
<reportElement x="240" y="30" width="100" height="30" uuid="1e81595e-56fc-4e88-8b31-9057cbb92486"/>
<textFieldExpression><![CDATA[$F{city}]]></textFieldExpression>
</textField>
</band>
</detail>
</jasperReport>