Jump to content
Changes to the Jaspersoft community edition download ×

Example to put two reports in a final one


2005 IR Help

Recommended Posts

By: badam - berndadam

Example to put two reports in a final one

2004-06-15 02:37

Hi,

 

I'am new on this great library, called JasperReports and I've a problem. I think it is simple for you, but it is to difficult for me.

I have two different reports, one is with pageHeader and pageFooter and a image between header and foooter on page 1 and the second is a normal report with pageHeader, columnHeder, detail and pageFooter and more with one page. The pageHeaders and pageFooters are the same.

Is there a simple possibility to put this different reports in the same fianl document. Can you give me an example for this.

 

Thank's.

 

Bernd

 

 

 

 

 

By: C-Box - c-box

RE: Example to put two reports in a final one

2004-06-15 03:43

So as far as I understand, you use two reports with the same pageheader/-footer just to let a kind of "title-picture" appear. And you did so, because the titleband should also have page-header/-footer like the rest of the report.

 

Perhaps this could help you:

 

1.) Create in your report two dummy groups and put your image within the groupheader of group1 and make the groupfooters bandheight to 0. Also the group2-bands should actually not get necessary, so make their height also to 0.

 

2.) set the attribute "startonnewpage" to the groups to true.

 

3.) design your page-header-footer that should appear on each page as normal within the same-named bands.

 

So that should work (in my opinion - but I didn't tried it yet)...

 

You also could use SubReports the one for the title-image and the other for the data, and put the first subreport in groupheader1 and the second in groupheader2. That should also work.

 

hth

C-Box

 

 

 

 

By: badam - berndadam

RE: Example to put two reports in a final one

2004-06-15 06:00

I've try that, what you wrote, but it doesn't work. I set the atribute "startonnewpage" to yes, but I don't see a new page. The data will write to the first page.

 

Here is my xml-File:

<?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="595"

pageHeight="842"

columnWidth="535"

columnSpacing="0"

leftMargin="30"

rightMargin="30"

topMargin="20"

bottomMargin="20"

whenNoDataType="NoPages"

isTitleNewPage="false"

isSummaryNewPage="false">

<queryString><![CDATA[select COSTCENTER, BEZEICHNUNG from Costcenter]]></queryString>

<field name="COSTCENTER" class="java.lang.Double"/>

<field name="BEZEICHNUNG" class="java.lang.String"/>

<group name="dummy1" isStartNewColumn="false" isStartNewPage="true" isResetPageNumber="false" isReprintHeaderOnEachPage="true" minHeightToStartNewPage="0" >

<groupExpression><![CDATA[null]]></groupExpression>

<groupHeader>

<band height="50" isSplitAllowed="true" >

<image scaleImage="FillFrame" vAlign="Top" hAlign="Left" isUsingCache="false" evaluationTime="Now" hyperlinkType="None"> <reportElement

mode="Opaque"

x="94"

y="4"

width="289"

height="39"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<graphicElement stretchType="NoStretch" pen="None" fill="Solid" />

<imageExpression class="java.lang.String"><![CDATA["D:\test.jpg"]]></imageExpression> </image>

</band>

</groupHeader>

<groupFooter>

<band height="0" isSplitAllowed="true" >

</band>

</groupFooter>

</group>

<group name="dummy2" isStartNewColumn="false" isStartNewPage="true" isResetPageNumber="false" isReprintHeaderOnEachPage="true" minHeightToStartNewPage="0" >

<groupExpression><![CDATA[null]]></groupExpression>

<groupHeader>

<band height="0" isSplitAllowed="true" >

</band>

</groupHeader>

<groupFooter>

<band height="0" isSplitAllowed="true" >

</band>

</groupFooter>

</group>

<background>

<band height="0" isSplitAllowed="true" >

</band>

</background>

<title>

<band height="50" isSplitAllowed="true" >

<staticText>

<reportElement

mode="Transparent"

x="61"

y="5"

width="412"

height="40"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Center" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="30" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<text><![CDATA[Gray Template]]></text>

</staticText>

</band>

</title>

<pageHeader>

<band height="9" isSplitAllowed="true" >

</band>

</pageHeader>

<columnHeader>

<band height="0" isSplitAllowed="true" >

<line direction="BottomUp">

<reportElement

mode="Opaque"

x="1"

y="50"

width="535"

height="0"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<graphicElement stretchType="NoStretch" pen="Thin" fill="Solid" />

</line>

</band>

</columnHeader>

<detail>

<band height="48" isSplitAllowed="true" >

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="162"

y="2"

width="367"

height="16"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.Double"><![CDATA[$F{COSTCENTER}]]></textFieldExpression>

</textField>

<staticText>

<reportElement

mode="Transparent"

x="0"

y="2"

width="267"

height="17"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" />

</textElement>

<text><![CDATA[COSTCENTER]]></text>

</staticText>

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="162"

y="20"

width="367"

height="16"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA[$F{BEZEICHNUNG}]]></textFieldExpression>

</textField>

<staticText>

<reportElement

mode="Transparent"

x="0"

y="20"

width="267"

height="17"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="" pdfFontName="Helvetica" size="12" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="Cp1250" isStrikeThrough="false" />

</textElement>

<text><![CDATA[bEZEICHNUNG]]></text>

</staticText>

</band>

</detail>

<columnFooter>

<band height="0" isSplitAllowed="true" >

</band>

</columnFooter>

<pageFooter>

<band height="27" isSplitAllowed="true" >

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="325"

y="4"

width="174"

height="19"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Right" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA["Page " + $V{PAGE_NUMBER} + " of "]]></textFieldExpression>

</textField>

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Report" hyperlinkType="None" > <reportElement

mode="Transparent"

x="499"

y="4"

width="36"

height="19"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.lang.String"><![CDATA["" + $V{PAGE_NUMBER}]]></textFieldExpression>

</textField>

<line direction="TopDown">

<reportElement

mode="Opaque"

x="1"

y="3"

width="535"

height="0"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<graphicElement stretchType="NoStretch" pen="2Point" fill="Solid" />

</line>

<textField isStretchWithOverflow="false" pattern="" isBlankWhenNull="false" evaluationTime="Now" hyperlinkType="None" > <reportElement

mode="Transparent"

x="1"

y="6"

width="209"

height="19"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<textElement textAlignment="Left" verticalAlignment="Top" lineSpacing="Single">

<font fontName="Helvetica" pdfFontName="Helvetica" size="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" pdfEncoding ="CP1252" isStrikeThrough="false" />

</textElement>

<textFieldExpression class="java.util.Date"><![CDATA[new Date()]]></textFieldExpression>

</textField>

</band>

</pageFooter>

<summary>

<band height="0" isSplitAllowed="true" >

</band>

</summary>

</jasperReport>

 

 

 

 

By: C-Box - c-box

RE: Example to put two reports in a final one

2004-06-15 07:19

Well it must work... I just know it, because I've read it in the tips&tricks of jaspers homepage...

 

see here...

http://jasperreports.sourceforge.net/tips.tricks.html#fake

 

that is exactly what you want to do, isn't it?

C-Box

 

 

 

 

By: badam - berndadam

RE: Example to put two reports in a final one

2004-06-16 02:32

Hi C-Box,

 

I've tried what you say, and it works fine. But on the first page I allways see the columnHeader. And I want to see only the pageHeader, the image and the pageFooter on the first page. Is it possible to supress the columnHeader on the first page?

 

Thanks Bernd

 

 

 

 

By: C-Box - c-box

RE: Example to put two reports in a final one

2004-06-16 03:06

Yes it is, just put that into the "printWhenExpression" attribute of the whole ColumnHeader/-Footerband:

 

new Boolean($V{PAGE_NUMBER}.intValue()>1)

 

so I do, to surpress some static-textfields that should not appear on first but on all following pages. :-)

 

hth

C-Box

 

 

 

 

By: badam - berndadam

RE: Example to put two reports in a final one

2004-06-17 06:10

Hi C-Box,

 

Now it works fine. Thank you.

 

Regards Bernd

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...