Jump to content
JasperReports Library 7.0 is now available ×

Help with simple sub-report


ktrinad

Recommended Posts

By: Mark Clarke - mxc4

Help with simple sub-report

2003-05-17 22:17

Hi people,

 

I am battling to get a simple sub-report to work. Both reports just have static text. THis is a test for a subreport which will just contain a jpg later.

Below is the code. The subreport prints as a stand-alon but not when used as a subreport. What am I doing wrong?

 

Thanks

PS: I have asked on the jasper forum but got no response so please don't be offended by any crosspost issues.

 

 

====================================

 

Master

 

 

=========================================

 

 

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

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

<title>

<band height="42">

</band>

</title>

<pageHeader>

<band height="0">

</band>

</pageHeader>

<columnHeader>

<band height="0">

</band>

</columnHeader>

<detail>

<band height="303">

<subreport isUsingCache="true">

<reportElement

mode="Opaque"

x="34"

y="62"

width="441"

height="224"

forecolor="#000000"

backcolor="#00FFFF"

positionType="Float"

isPrintRepeatedValues="false"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<subreportExpression class="java.lang.String"><![CDATA["TurnAround.jasper"]]></subreportExpression>

</subreport>

<staticText>

<reportElement

mode="Transparent"

x="125"

y="8"

width="307"

height="44"

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="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<text>Test Text</text>

</staticText>

</band>

</detail>

<columnFooter>

<band height="0">

</band>

</columnFooter>

<pageFooter>

<band height="0">

</band>

</pageFooter>

<summary>

<band height="0">

</band>

</summary>

</jasperReport>

 

=====================================

 

child

 

=======================================

 

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

columnCount="1"

printOrder="Vertical"

orientation="Portrait"

pageWidth="220"

pageHeight="150"

columnWidth="220"

columnSpacing="0"

leftMargin="0"

rightMargin="0"

topMargin="0"

bottomMargin="0"

whenNoDataType="NoPages"

scriptletClass="TurnAroundChart"

isTitleNewPage="false"

isSummaryNewPage="false">

<variable name="TurnAroundImage" class="java.awt.Image" resetType="Report" calculation="System">

</variable>

<title>

<band height="8">

</band>

</title>

<pageHeader>

<band height="0">

</band>

</pageHeader>

<columnHeader>

<band height="0">

</band>

</columnHeader>

<detail>

<band height="100">

<staticText>

<reportElement

mode="Opaque"

x="8"

y="12"

width="197"

height="77"

forecolor="#000000"

backcolor="#FFFFFF"

positionType="Float"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="true"/>

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

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

</textElement>

<text>TEST</text>

</staticText>

</band>

</detail>

<columnFooter>

<band height="0">

</band>

</columnFooter>

<pageFooter>

<band height="0">

</band>

</pageFooter>

<summary>

<band height="0">

</band>

</summary>

</jasperReport>

 

 

 

 

 

 

By: Mark Clarke - mxc4

oops - leave out the scripting variable.

2003-05-17 22:43

Hi there,

 

Sorry, I left in a scripting variable which will generate errors if you try it out on your side. Please remove the scripletClass attribute from the subreports report element.

 

 

 

 

 

 

By: Giulio Toffoli - gt78

RE: Help with simple sub-report

2003-05-18 03:43

Hi Mark. If you make a report without using a resultset or a datasource, you can not use the detail band. You should use the title band or summary band. Another thing: if the report is not the result of a list of records (your report has zero records), you should say to jasper that you want "AllSectionNoDetail". Set it in the report properties form (tab "more...").

 

This is a sample (your sample corrected)....

 

 

MASTER______________________-

 

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

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

<background>

<band height="0">

</band>

</background>

<title>

<band height="157">

<subreport isUsingCache="true">

<reportElement

mode="Transparent"

x="44"

y="46"

width="220"

height="22"

forecolor="#000000"

backcolor="#00FFFF"

positionType="Float"

isPrintRepeatedValues="false"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

<subreportExpression class="java.lang.String"><![CDATA["c:\documenti\progetti\ireport\tmp\child.jasper"]]></subreportExpression>

</subreport>

<staticText>

<reportElement

mode="Transparent"

x="130"

y="24"

width="307"

height="14"

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="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<text>Test Text</text>

</staticText>

<staticText>

<reportElement

mode="Transparent"

x="127"

y="81"

width="307"

height="14"

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="10" isBold="false" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<text>Test Textvd</text>

</staticText>

</band>

</title>

<pageHeader>

<band height="0">

</band>

</pageHeader>

<columnHeader>

<band height="0">

</band>

</columnHeader>

<detail>

<band height="0">

</band>

</detail>

<columnFooter>

<band height="0">

</band>

</columnFooter>

<pageFooter>

<band height="0">

</band>

</pageFooter>

<summary>

<band height="0">

</band>

</summary>

</jasperReport>

 

 

CHILD____________________________

 

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

columnCount="1"

printOrder="Vertical"

orientation="Portrait"

pageWidth="220"

pageHeight="150"

columnWidth="220"

columnSpacing="0"

leftMargin="0"

rightMargin="0"

topMargin="0"

bottomMargin="0"

whenNoDataType="AllSectionsNoDetail"

isTitleNewPage="false"

isSummaryNewPage="false">

<variable name="TurnAroundImage" class="java.awt.Image" resetType="Report" calculation="System">

</variable>

<background>

<band height="0">

</band>

</background>

<title>

<band height="108">

<staticText>

<reportElement

mode="Opaque"

x="7"

y="17"

width="210"

height="77"

forecolor="#000000"

backcolor="#8080FF"

positionType="FixRelativeToTop"

isPrintRepeatedValues="true"

isRemoveLineWhenBlank="false"

isPrintInFirstWholeBand="false"

isPrintWhenDetailOverflows="false"/>

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

<font fontName="" pdfFontName="Helvetica-Bold" size="26" isBold="true" isItalic="false" isUnderline="false" isPdfEmbedded ="false" isStrikeThrough="false" />

</textElement>

<text>TEST subreport</text>

</staticText>

</band>

</title>

<pageHeader>

<band height="0">

</band>

</pageHeader>

<columnHeader>

<band height="0">

</band>

</columnHeader>

<detail>

<band height="0">

</band>

</detail>

<columnFooter>

<band height="0">

</band>

</columnFooter>

<pageFooter>

<band height="0">

</band>

</pageFooter>

<summary>

<band height="0">

</band>

</summary>

</jasperReport>

 

 

__________________________________

 

I hope this helps you

 

Giulio

 

 

 

 

By: Mark Clarke - mxc4

RE: Help with simple sub-report

2003-05-18 05:27

Thanks!

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