subreports whose sizes vary dynamically

By: Anchal Agarwal - anchal
subreports whose sizes vary dynamically
2003-03-03 03:50
Hi,

Please consider this as urgent.

Problem:
I have a master report that has 8 subreports. Each of these subreports inturn can have 1 to 17 subreports.
The design layout is such that one subreport is to be displayed below the other (applies to sub-subreports also).
The number of records in each of these sub-subreports varies dynamically. This means that number of records of one sub-subreport decides the value of 'y' attribute for it's subsequent sub-subreport in the detail section of the parent subreport xml. This also means that I need to have a variable band for the detail sections in subreports and also in the master xml.
I tried many solutions to solve this problem. I tried splitting the detail section by moving one subreport element of the master to the title section and keeping the other in the detail section. This works fine when I have only two subreports and when the sub-subreport data fits the page height. But I don't know how to make things work with 8 subreports in the master and with sub-subreports producing records that cross the page height limit. Also during report fill, the processing goes into an infinite loop never producing the JasperPrint object.
I read that if the band size crosses the page height limit, then it should be split into dummy group headers. But I do not understand how to achieve this at runtime.

Also I want to have each subreport beginning on a new page. The same goes for sub-subreports if there is no way to have a sub-subreport follow the previous one immediately after the previous one ends.

Please find the XMLs for one master, two subreports and 3 sub-subreports. (I want to make it work for 1 master, 8 subreports and 17 sub-subreports)
*************************************
master (MyReport.xml)
....
....
<title>
<band height="70">
<rectangle>
<reportElement x="0" y="5" width="515" height="40" backcolor="#333333"/>
<graphicElement stretchType="NoStretch" pen="None"/>
</rectangle>
<staticText>
<reportElement x="0" y="8" width="515" height="15" forecolor="#FFFFFF" backcolor="#333333" mode="Opaque"/>
<textElement textAlignment="Center">
<font reportFont="Arial_Bold"/>
</textElement>
<text>My Company</text>
</staticText>
<staticText>
<reportElement x="0" y="26" width="515" height="15" forecolor="#FFFFFF" backcolor="#333333" mode="Opaque"/>
<textElement textAlignment="Center">
<font reportFont="Arial_Bold"/>
</textElement>
<text>REPORT</text>
</staticText>
<subreport isUsingCache="true">
<parametersMapExpression>
$P{paramAuditSection0}
</parametersMapExpression>
<dataSourceExpression>
$P{dsAuditSection0}
</dataSourceExpression>
<subreportExpression class="dori.jasper.engine.JasperReport">
$P{AuditSection0}
</subreportExpression>
</subreport>
</band>
</title>
<detail>
<band height="70">
<subreport isUsingCache="true">
<parametersMapExpression>
$P{paramAuditSection1}
</parametersMapExpression>
<dataSourceExpression>
$P{dsAuditSection1}
</dataSourceExpression>
<subreportExpression class="dori.jasper.engine.JasperReport">
$P{AuditSection1}
</subreportExpression>
</subreport>
</band>
</detail>
....
*************************************
subreport (AuditSection0 [AuditSection1 is similar but different sub-subreports])
....
....
<title>
<band height="30">
<rectangle>
<reportElement x="0" y="5" width="515" height="15" backcolor="#333333"/>
<graphicElement stretchType="NoStretch" pen="None"/>
</rectangle>
<textField>
<reportElement x="0" y="8" width="515" height="15" forecolor="#FFFFFF" backcolor="#333333" mode="Opaque"/>
<textElement textAlignment="Left">
<font reportFont="Arial_Bold"/>
</textElement>
<textFieldExpression class="java.lang.String">
$P{AuditSectionTitle}
</textFieldExpression>
</textField>
</band>
</title>
<detail>
<band height="65">
<!-- The subreport elements for this band are generated dynamically depending upon which subreports belong to this Audit Section
-->
</band>
</detail>
..........
**********************
sub-subreport (SPRREP0 [SPRREP1, SPRREP2 are similar with different fields])
....
....
<group name="TransactionType" minHeightToStartNewPage="60">
<groupExpression>
$F{transactionTypeCD}
</groupExpression>
</group>
<pageHeader>
<band height="30">
<staticText>
<reportElement x="0" y="5" width="50" height="20" forecolor="#FFFFFF" backcolor="#293163" mode="Opaque"/>
<textElement textAlignment="Left">
<font reportFont="Arial_Normal"/>
</textElement>
<text>Account</text>
</staticText>
<staticText>
<reportElement x="55" y="5" width="50" height="20" forecolor="#FFFFFF" backcolor="#293163" mode="Opaque"/>
<textElement>
<font reportFont="Arial_Normal"/>
</textElement>
<text>Account Type</text>
</staticText>
</band>
</pageHeader>
<detail>
<band height="20">
<textField isBlankWhenNull="true">
<reportElement x="0" y="5" width="50" height="15" />
<textElement textAlignment="Left">
<font reportFont="Arial_Normal" size="9"/>
</textElement>
<textFieldExpression class="java.lang.String">
$F{account}
</textFieldExpression>
</textField>
<textField isBlankWhenNull="true" isStretchWithOverflow="true">
<reportElement x="55" y="5" width="50" height="15" positionType="Float" />
<textElement textAlignment="Left">
<font reportFont="Arial_Normal" size="9"/>
</textElement>
<textFieldExpression class="java.lang.String">
$F{accountType}
</textFieldExpression>
</textField>
<line>
<reportElement x="0" y="20" width="110" height="0" forecolor="#808080" positionType="Float"/>
<graphicElement stretchType="NoStretch"/>
</line>
</band>
</detail>
......
***********************
Thanks in advance,
Anchal.
2002 JI Open Discussion's picture
Joined: Aug 10 2006 - 3:28am
Last seen: 17 years 1 month ago

0 Answers:

No answers yet
Feedback
randomness