Jump to content

Generation xls from report with two subreport.


abdujaparov

Recommended Posts

Hi,

I've been trying for days to generate a report. A report is composed by two subreport.

I changed the report in this way:

Main report


<?xml version="1.0" encoding="UTF-8"  ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
         name="Excel"
         columnCount="1"
         printOrder="Vertical"
         orientation="Portrait"
         pageWidth="595"
         pageHeight="842"
         columnWidth="535"
         columnSpacing="0"
         leftMargin="30"
         rightMargin="30"
         topMargin="20"
         bottomMargin="20"
         whenNoDataType="NoPages"
         isTitleNewPage="false"
         isSummaryNewPage="false">
    <property name="ireport.scriptlethandling" value="0" />
    <property name="ireport.encoding" value="UTF-8" />
    <import value="java.util.*" />
    <import value="net.sf.jasperreports.engine.*" />
    <import value="net.sf.jasperreports.engine.data.*" />
    <parameter name="subReportFondi" class="java.lang.Object"/>
    <parameter name="subReportGestore" class="java.lang.Object"/>

    <queryString><![CDATA[sELECT TRUNC(SYSDATE) AS DATA
FROM DUAL]]></queryString>

    <field name="DATA" class="java.sql.Timestamp"/>
   


        <background>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </background>
        <title>
            <band height="67"  isSplitAllowed="true" >
                <image  evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
                    <reportElement
                        x="1"
                        y="1"
                        width="364"
                        height="66"
                        key="image-1"/>
                    <box></box>
                    <graphicElement stretchType="NoStretch"/>
                    <imageExpression class="java.lang.String"><![CDATA["/findb/sw/fin/java/CreateReportCPPI/reports/logoBancaIMI.jpg"]]></imageExpression>
                </image>
            </band>
        </title>
        <pageHeader>
            <band height="133"  isSplitAllowed="true" >
                <staticText>
                    <reportElement
                        mode="Opaque"
                        x="111"
                        y="0"
                        width="424"
                        height="33"
                        forecolor="#000000"
                        key="subscriptionFORM"
                        positionType="Float"/>
                    <box></box>
                    <textElement textAlignment="Center" verticalAlignment="Middle">
                        <font fontName="Arial" size="16" isUnderline="true"/>
                    </textElement>
                <text><![CDATA[sUBSCRIPTION FORM]]></text>
                </staticText>
                <staticText>
                    <reportElement
                        x="1"
                        y="1"
                        width="109"
                        height="32"
                        key="from"/>
                    <box></box>
                    <textElement textAlignment="Left" verticalAlignment="Bottom">
                        <font fontName="Arial"/>
                    </textElement>
                <text><![CDATA[From:]]></text>
                </staticText>
                <staticText>
                    <reportElement
                        x="1"
                        y="33"
                        width="135"
                        height="23"
                        key="bancaImiSPA"/>
                    <box></box>
                    <textElement textAlignment="Left" verticalAlignment="Middle">
                        <font fontName="Arial" pdfFontName="Helvetica-Bold" isBold="true"/>
                    </textElement>
                <text><![CDATA[bANCA IMI SPA]]></text>
                </staticText>
                <staticText>
                    <reportElement
                        x="1"
                        y="77"
                        width="341"
                        height="23"
                        key="telefono1"/>
                    <box></box>
                    <textElement verticalAlignment="Middle">
                        <font fontName="Arial"/>
                    </textElement>
                <text><![CDATA[TEL: #39-02.7261.5463(Enrico COTTINI) or .5446 (Paolo FOSCHIANO)]]></text>
                </staticText>
                <staticText>
                    <reportElement
                        x="1"
                        y="100"
                        width="341"
                        height="23"
                        key="confirmationTxt"/>
                    <box></box>
                    <textElement verticalAlignment="Middle">
                        <font fontName="Arial"/>
                    </textElement>
                <text><![CDATA[PLEASE SEND CONFIRMATIONS TO: #39-02.7261.5217]]></text>
                </staticText>
                <staticText>
                    <reportElement
                        x="1"
                        y="54"
                        width="296"
                        height="23"
                        key="staticText-10"/>
                    <box></box>
                    <textElement verticalAlignment="Middle">
                        <font fontName="Arial" pdfFontName="Helvetica-Bold" isBold="true"/>
                    </textElement>
                <text><![CDATA[Piazzetta Giordano Dell'Amore, 3 - 20121 - MILANO]]></text>
                </staticText>
            </band>
        </pageHeader>
        <columnHeader>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </columnHeader>
        <detail>
            <band height="135"  isSplitAllowed="true" >
                <line direction="TopDown">
                    <reportElement
                        x="1"
                        y="3"
                        width="534"
                        height="0"
                        key="line-1"/>
                    <graphicElement stretchType="NoStretch"/>
                </line>
                <subreport  isUsingCache="true">
                    <reportElement
                        x="1"
                        y="5"
                        width="534"
                        height="126"
                        key="subreport-1"/>
                    <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>   
                    <subreportExpression  class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$P{subReportGestore}]]></subreportExpression>
                </subreport>
            </band>
        </detail>
        <columnFooter>
            <band height="30"  isSplitAllowed="true" >
                <line direction="TopDown">
                    <reportElement
                        x="1"
                        y="1"
                        width="534"
                        height="0"
                        key="line-2"/>
                    <graphicElement stretchType="NoStretch"/>
                </line>
            </band>
        </columnFooter>
        <pageFooter>
            <band height="224"  isSplitAllowed="true" >
                <staticText>
                    <reportElement
                        x="1"
                        y="1"
                        width="534"
                        height="23"
                        key="subscrptio2"/>
                    <box></box>
                    <textElement textAlignment="Center" verticalAlignment="Middle">
                        <font fontName="Arial" pdfFontName="Helvetica-Bold" size="12" isBold="true" isUnderline="true"/>
                    </textElement>
                <text><![CDATA[sUBSCRIPTION FORM]]></text>
                </staticText>
                <subreport  isUsingCache="true">
                    <reportElement
                        x="1"
                        y="104"
                        width="534"
                        height="78"
                        key="subreport-2"/>
                    <connectionExpression><![CDATA[$P{REPORT_CONNECTION}]]></connectionExpression>   
                    <subreportExpression  class="net.sf.jasperreports.engine.JasperReport"><![CDATA[$P{subReportFondi}]]></subreportExpression>
                </subreport>
                <staticText>
                    <reportElement
                        x="1"
                        y="23"
                        width="249"
                        height="23"
                        key="clientDesign"/>
                    <box></box>
                    <textElement verticalAlignment="Middle">
                        <font fontName="Arial"/>
                    </textElement>
                <text><![CDATA[Client designation: Banca IMI spa - Strategie Attive]]></text>
                </staticText>
                <staticText>
                    <reportElement
                        x="1"
                        y="46"
                        width="59"
                        height="23"
                        key="account"/>
                    <box></box>
                    <textElement verticalAlignment="Middle">
                        <font fontName="Arial"/>
                    </textElement>
                <text><![CDATA[Account:]]></text>
                </staticText>
                <staticText>
                    <reportElement
                        x="23"
                        y="193"
                        width="146"
                        height="23"
                        key="noDelivery"/>
                    <box></box>
                    <textElement verticalAlignment="Middle">
                        <font fontName="Arial"/>
                    </textElement>
                <text><![CDATA[No delivery of certificates.]]></text>
                </staticText>
                <staticText>
                    <reportElement
                        x="23"
                        y="81"
                        width="100"
                        height="23"
                        key="nomeFondo-1"/>
                    <box>                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineColor="#000000"/>
                    <rightPen lineWidth="0.0" lineStyle="Solid" lineColor="#000000"/>
</box>
                    <textElement verticalAlignment="Bottom">
                        <font fontName="Arial"/>
                    </textElement>
                <text><![CDATA[Fund Name]]></text>
                </staticText>
                <staticText>
                    <reportElement
                        x="123"
                        y="81"
                        width="39"
                        height="23"
                        key="staticText-5"/>
                    <box>                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
                    <textElement verticalAlignment="Bottom">
                        <font fontName="Arial"/>
                    </textElement>
                <text><![CDATA[share class]]></text>
                </staticText>
                <staticText>
                    <reportElement
                        x="162"
                        y="81"
                        width="74"
                        height="23"
                        key="staticText-6"/>
                    <box>                    <topPen lineWidth="1.0" lineStyle="Solid"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid"/>
</box>
                    <textElement verticalAlignment="Bottom">
                        <font fontName="Arial"/>
                    </textElement>
                <text><![CDATA[iSIN CODE]]></text>
                </staticText>
                <staticText>
                    <reportElement
                        x="236"
                        y="81"
                        width="55"
                        height="23"
                        key="staticText-7"/>
                    <box>                    <pen lineWidth="0.0" lineStyle="Solid"/>
                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
                    <textElement verticalAlignment="Bottom">
                        <font fontName="Arial"/>
                    </textElement>
                <text><![CDATA[CASH AMOUNT]]></text>
                </staticText>
                <staticText>
                    <reportElement
                        x="291"
                        y="81"
                        width="62"
                        height="23"
                        key="staticText-8"/>
                    <box>                    <topPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <leftPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineStyle="Solid" lineColor="#000000"/>
</box>
                    <textElement verticalAlignment="Bottom">
                        <font fontName="Arial"/>
                    </textElement>
                <text><![CDATA[PAYMENT CURRENCY]]></text>
                </staticText>
                <staticText>
                    <reportElement
                        x="353"
                        y="81"
                        width="46"
                        height="23"
                        key="staticText-9"/>
                    <box>                    <topPen lineWidth="1.0" lineColor="#000000"/>
                    <bottomPen lineWidth="1.0" lineColor="#000000"/>
                    <rightPen lineWidth="1.0" lineColor="#000000"/>
</box>
                    <textElement verticalAlignment="Bottom">
                        <font fontName="Arial"/>
                    </textElement>
                <text><![CDATA[internal Code]]></text>
                </staticText>
            </band>
        </pageFooter>
        <lastPageFooter>
            <band height="155"  isSplitAllowed="true" >
                <staticText>
                    <reportElement
                        x="180"
                        y="55"
                        width="59"
                        height="23"
                        key="staticText-2"/>
                    <box></box>
                    <textElement textAlignment="Right" verticalAlignment="Bottom">
                        <font fontName="Arial"/>
                    </textElement>
                <text><![CDATA[Milan,]]></text>
                </staticText>
                <textField isStretchWithOverflow="false" isBlankWhenNull="true" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
                    <reportElement
                        x="180"
                        y="77"
                        width="57"
                        height="23"
                        key="textField-2"/>
                    <box></box>
                    <textElement>
                        <font/>
                    </textElement>
                <textFieldExpression   class="java.sql.Timestamp"><![CDATA[$F{DATA}]]></textFieldExpression>
                </textField>
                <staticText>
                    <reportElement
                        x="330"
                        y="55"
                        width="127"
                        height="23"
                        key="staticText-3"/>
                    <box></box>
                    <textElement textAlignment="Left" verticalAlignment="Bottom">
                        <font fontName="Arial"/>
                    </textElement>
                <text><![CDATA[Authorized Signature:]]></text>
                </staticText>
                <image  evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
                    <reportElement
                        x="331"
                        y="78"
                        width="111"
                        height="50"
                        key="image-2"/>
                    <box></box>
                    <graphicElement stretchType="NoStretch"/>
                    <imageExpression class="java.lang.String"><![CDATA["/findb/sw/fin/java/CreateReportCPPI/reports/firmaCottini.jpg"]]></imageExpression>
                </image>
                <staticText>
                    <reportElement
                        x="332"
                        y="130"
                        width="111"
                        height="23"
                        key="staticText-4"/>
                    <box></box>
                    <textElement textAlignment="Center" verticalAlignment="Middle">
                        <font fontName="Arial"/>
                    </textElement>
                <text><![CDATA[(Enrico Cottini)]]></text>
                </staticText>
            </band>
        </lastPageFooter>
        <summary>
            <band height="131"  isSplitAllowed="true" >
            </band>
        </summary>
</jasperReport>
 

 

subGestorore.jxrml (first subreport):

 


<?xml version="1.0" encoding="UTF-8"  ?>
<!-- Created with iReport - A designer for JasperReports -->
<!DOCTYPE jasperReport PUBLIC "//JasperReports//DTD Report Design//EN" "http://jasperreports.sourceforge.net/dtds/jasperreport.dtd">
<jasperReport
         name="classic"
         columnCount="1"
         printOrder="Vertical"
         orientation="Portrait"
         pageWidth="535"
         pageHeight="802"
         columnWidth="535"
         columnSpacing="0"
         leftMargin="0"
         rightMargin="0"
         topMargin="0"
         bottomMargin="0"
         whenNoDataType="AllSectionsNoDetail"
         isTitleNewPage="false"
         isSummaryNewPage="false">
    <property name="ireport.scriptlethandling" value="0" />
    <property name="ireport.encoding" value="UTF-8" />
    <import value="java.util.*" />
    <import value="net.sf.jasperreports.engine.*" />
    <import value="net.sf.jasperreports.engine.data.*" />

    <queryString><![CDATA[sELECT B.NOME_GESTORE AS GESTORE, B.INDIRIZZO1, B.INDIRIZZO2, B.INDIRIZZO3,
B.INDIRIZZO4, B.TELEFONO AS TELGESTORE, B.FAX AS FAXGESTORE
FROM CPPI_GESTORI B
WHERE B.NOME_GESTORE=PIPPO]]></queryString>

    <field name="GESTORE" class="java.lang.String"/>
    <field name="INDIRIZZO1" class="java.lang.String"/>
    <field name="INDIRIZZO2" class="java.lang.String"/>
    <field name="INDIRIZZO3" class="java.lang.String"/>
    <field name="INDIRIZZO4" class="java.lang.String"/>
    <field name="TELGESTORE" class="java.lang.String"/>
    <field name="FAXGESTORE" class="java.lang.String"/>

        <background>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </background>
        <title>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </title>
        <pageHeader>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </pageHeader>
        <columnHeader>
            <band height="0"  isSplitAllowed="true" >
            </band>
        </columnHeader>
        <detail>
            <band height="266"  isSplitAllowed="true" >
                <staticText>
                    <reportElement
                        x="23"
                        y="0"
                        width="162"
                        height="23"
                        key="numberPage"/>
                    <box></box>
                    <textElement verticalAlignment="Middle">
                        <font fontName="Arial"/>
                    </textElement>
                <text><![CDATA[Number of Pages (including this):]]></text>
                </staticText>
                <staticText>
                    <reportElement
                        x="23"
                        y="23"
                        width="24"
                        height="23"
                        key="to"/>
                    <box></box>
                    <textElement verticalAlignment="Middle">
                        <font fontName="Arial"/>
                    </textElement>
                <text><![CDATA[To:]]></text>
                </staticText>
                <textField isStretchWithOverflow="true" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
                    <reportElement
                        x="23"
                        y="46"
                        width="134"
                        height="23"
                        key="gestoreField"/>
                    <box></box>
                    <textElement textAlignment="Left" verticalAlignment="Middle">
                        <font fontName="Arial" pdfFontName="Helvetica-Bold" size="11" isBold="true"/>
                    </textElement>
                <textFieldExpression   class="java.lang.String"><![CDATA[$F{GESTORE}]]></textFieldExpression>
                </textField>
                <textField isStretchWithOverflow="true" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None"  hyperlinkTarget="Self" >
    &

Link to comment
Share on other sites

  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...