1

Olá!Minha aplicação tem que fazer um relatório com dois sub relatórios,um deles fica em cima do outro,q é o subrelatório de conhecimentos,alguem sabe pq?

Código relatório conhecimentos:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b  -->
<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="SubCo" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="842" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="b13071d7-55cd-4769-a1fc-d58cb7a3c9a6">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Servidor Far"/>
    <parameter name="numeroDocumentoCobranca" class="java.lang.Double"/>
    <queryString>
        <![CDATA[SELECT numero_conhecimento,serie_conhecimento,data_emissao_conhecimento,valor_frete FROM ph161169_fatura_pagar WHERE numero_documento_cobranca = $P{numeroDocumentoCobranca}]]>
    </queryString>
    <field name="serie_conhecimento" class="java.lang.Double"/>
    <field name="numero_conhecimento" class="java.lang.Double"/>
    <field name="data_emissao_conhecimento" class="java.util.Date"/>
    <field name="valor_frete" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="53" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="10" width="160" height="30" uuid="0d28e896-3ec6-47a2-9688-235b65e66ba3"/>
                <textElement>
                    <font size="16" isBold="true"/>
                </textElement>
                <text><![CDATA[Notas Fiscais]]></text>
            </staticText>
        </band>
    </title>
    <columnHeader>
        <band height="40" splitType="Stretch">
            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
            <staticText>
                <reportElement x="0" y="0" width="142" height="40" uuid="33c16c28-f3ad-4372-a47d-9dd59cc01735">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="eb31812e-f740-4b5a-b134-42877ad91ba3"/>
                </reportElement>
                <textElement>
                    <font size="13" isBold="true"/>
                </textElement>
                <text><![CDATA[Série:]]></text>
            </staticText>
            <staticText>
                <reportElement x="142" y="0" width="140" height="40" uuid="b263fdf0-142a-493d-8db0-b546b2d40cf3">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="eb31812e-f740-4b5a-b134-42877ad91ba3"/>
                </reportElement>
                <textElement>
                    <font size="13" isBold="true"/>
                </textElement>
                <text><![CDATA[Número:]]></text>
            </staticText>
            <staticText>
                <reportElement x="282" y="0" width="140" height="40" uuid="c04244bd-420d-4b65-9734-a8bac3e17300">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="eb31812e-f740-4b5a-b134-42877ad91ba3"/>
                </reportElement>
                <textElement>
                    <font size="13" isBold="true"/>
                </textElement>
                <text><![CDATA[Data Emissão:]]></text>
            </staticText>
            <staticText>
                <reportElement x="562" y="0" width="140" height="40" uuid="d45efca9-5d54-4556-bab9-18036b2240d5">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="eb31812e-f740-4b5a-b134-42877ad91ba3"/>
                </reportElement>
                <textElement>
                    <font size="13" isBold="true"/>
                </textElement>
                <text><![CDATA[Valor frete:]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="51" splitType="Stretch">
            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
            <textField>
                <reportElement x="0" y="0" width="142" height="51" uuid="5fdaa9f0-9973-4668-b946-1c756439bdd0">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="eb31812e-f740-4b5a-b134-42877ad91ba3"/>
                </reportElement>
                <textElement>
                    <font size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{serie_conhecimento}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="142" y="0" width="140" height="51" uuid="092b57e7-2f7c-4686-8462-347c62839e8d">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="eb31812e-f740-4b5a-b134-42877ad91ba3"/>
                </reportElement>
                <textElement>
                    <font size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{numero_conhecimento}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="282" y="0" width="140" height="51" uuid="381c9f77-6a2e-4549-9dc2-5d14d9948210">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="eb31812e-f740-4b5a-b134-42877ad91ba3"/>
                </reportElement>
                <textElement>
                    <font size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{data_emissao_conhecimento}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="562" y="0" width="140" height="51" uuid="4bd6547a-72e2-4ee8-94ed-7d3104b9e818">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="eb31812e-f740-4b5a-b134-42877ad91ba3"/>
                </reportElement>
                <textElement>
                    <font size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{valor_frete}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>

Código relatório principal:

<?xml version="1.0" encoding="UTF-8"?>
<!-- Created with Jaspersoft Studio version 6.8.0.final using JasperReports Library version 6.8.0-2ed8dfabb690ff337a5797129f2cd92902b0c87b  -->
<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="SubCo" pageWidth="842" pageHeight="595" orientation="Landscape" columnWidth="842" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" uuid="b13071d7-55cd-4769-a1fc-d58cb7a3c9a6">
    <property name="com.jaspersoft.studio.data.defaultdataadapter" value="Servidor Far"/>
    <parameter name="numeroDocumentoCobranca" class="java.lang.Double"/>
    <queryString>
        <![CDATA[SELECT numero_conhecimento,serie_conhecimento,data_emissao_conhecimento,valor_frete FROM ph161169_fatura_pagar WHERE numero_documento_cobranca = $P{numeroDocumentoCobranca}]]>
    </queryString>
    <field name="serie_conhecimento" class="java.lang.Double"/>
    <field name="numero_conhecimento" class="java.lang.Double"/>
    <field name="data_emissao_conhecimento" class="java.util.Date"/>
    <field name="valor_frete" class="java.lang.String"/>
    <background>
        <band splitType="Stretch"/>
    </background>
    <title>
        <band height="53" splitType="Stretch">
            <staticText>
                <reportElement x="0" y="10" width="160" height="30" uuid="0d28e896-3ec6-47a2-9688-235b65e66ba3"/>
                <textElement>
                    <font size="16" isBold="true"/>
                </textElement>
                <text><![CDATA[Notas Fiscais]]></text>
            </staticText>
        </band>
    </title>
    <columnHeader>
        <band height="40" splitType="Stretch">
            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
            <staticText>
                <reportElement x="0" y="0" width="142" height="40" uuid="33c16c28-f3ad-4372-a47d-9dd59cc01735">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="eb31812e-f740-4b5a-b134-42877ad91ba3"/>
                </reportElement>
                <textElement>
                    <font size="13" isBold="true"/>
                </textElement>
                <text><![CDATA[Série:]]></text>
            </staticText>
            <staticText>
                <reportElement x="142" y="0" width="140" height="40" uuid="b263fdf0-142a-493d-8db0-b546b2d40cf3">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="eb31812e-f740-4b5a-b134-42877ad91ba3"/>
                </reportElement>
                <textElement>
                    <font size="13" isBold="true"/>
                </textElement>
                <text><![CDATA[Número:]]></text>
            </staticText>
            <staticText>
                <reportElement x="282" y="0" width="140" height="40" uuid="c04244bd-420d-4b65-9734-a8bac3e17300">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="eb31812e-f740-4b5a-b134-42877ad91ba3"/>
                </reportElement>
                <textElement>
                    <font size="13" isBold="true"/>
                </textElement>
                <text><![CDATA[Data Emissão:]]></text>
            </staticText>
            <staticText>
                <reportElement x="562" y="0" width="140" height="40" uuid="d45efca9-5d54-4556-bab9-18036b2240d5">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="eb31812e-f740-4b5a-b134-42877ad91ba3"/>
                </reportElement>
                <textElement>
                    <font size="13" isBold="true"/>
                </textElement>
                <text><![CDATA[Valor frete:]]></text>
            </staticText>
        </band>
    </columnHeader>
    <detail>
        <band height="51" splitType="Stretch">
            <property name="com.jaspersoft.studio.layout" value="com.jaspersoft.studio.editor.layout.FreeLayout"/>
            <textField>
                <reportElement x="0" y="0" width="142" height="51" uuid="5fdaa9f0-9973-4668-b946-1c756439bdd0">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="eb31812e-f740-4b5a-b134-42877ad91ba3"/>
                </reportElement>
                <textElement>
                    <font size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{serie_conhecimento}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="142" y="0" width="140" height="51" uuid="092b57e7-2f7c-4686-8462-347c62839e8d">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="eb31812e-f740-4b5a-b134-42877ad91ba3"/>
                </reportElement>
                <textElement>
                    <font size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{numero_conhecimento}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="282" y="0" width="140" height="51" uuid="381c9f77-6a2e-4549-9dc2-5d14d9948210">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="eb31812e-f740-4b5a-b134-42877ad91ba3"/>
                </reportElement>
                <textElement>
                    <font size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{data_emissao_conhecimento}]]></textFieldExpression>
            </textField>
            <textField>
                <reportElement x="562" y="0" width="140" height="51" uuid="4bd6547a-72e2-4ee8-94ed-7d3104b9e818">
                    <property name="com.jaspersoft.studio.spreadsheet.connectionID" value="eb31812e-f740-4b5a-b134-42877ad91ba3"/>
                </reportElement>
                <textElement>
                    <font size="12"/>
                </textElement>
                <textFieldExpression><![CDATA[$F{valor_frete}]]></textFieldExpression>
            </textField>
        </band>
    </detail>
    <summary>
        <band height="42" splitType="Stretch"/>
    </summary>
</jasperReport>

A pagina fica assim,todos os dados misturados.inserir a descrição da imagem aqui

2 Respostas 2

1

Ola voce precisa marcar no posicionamento do subreport que esta em baixo como flow, para que ele possa flutuar livremente sem ficar por cima do primeiro subreport

-1

Pode ser dois motivos, dentro do Jasper o subreport deve estar como float;

inserir a descrição da imagem aqui

Tambem deve se atender a tag "y", veja que neste exemplo tenho 3 subreports;

<band height="66" splitType="Stretch">
        <subreport>
            <reportElement positionType="Float" x="1" y="0" width="553" height="20" uuid="dcb4de43-b64f-4e50-a4b1-5ad31a1cd9a2"/>
            <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("carga.ordens")]]></dataSourceExpression>
            <subreportExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportExpression>
        </subreport>
        <subreport>
            <reportElement positionType="Float" x="1" y="20" width="553" height="20" uuid="dcb4de43-b64f-4e50-a4b1-5ad31a1cd9a2"/>
            <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("carga.ordens.itens")]]></dataSourceExpression>
            <subreportExpression><![CDATA[$P{SUBREPORT_DIR1}]]></subreportExpression>
        </subreport>
        <subreport>
            <reportElement positionType="Float" x="1" y="40" width="553" height="20" uuid="dcb4de43-b64f-4e50-a4b1-5ad31a1cd9a2"/>
            <dataSourceExpression><![CDATA[((net.sf.jasperreports.engine.data.JsonDataSource)$P{REPORT_DATA_SOURCE}).subDataSource("carga.ordens.pedidos")]]></dataSourceExpression>
            <subreportExpression><![CDATA[$P{SUBREPORT_DIR2}]]></subreportExpression>
        </subreport>
    </band>

Você deve fazer log-in para responder a esta pergunta.