Subreport Overlap each other

Hi All,

I have a question regarding the subreports. Requirement is to have 5 subreports one below another.

If each subreport contains only one row then it shows correctly but for more than one rows in each report (area for one report increases)they started overlapping each other.

As there are more rows in the first subreport second subreport should start once first is finished but it does start at the same pixel positions as it started with single row.

Any idea how can I ask the subreport to start when last subreport is finshed showing its rows.

Thanks in advance
inditrozen's picture
Joined: Jan 26 2008 - 8:47am
Last seen: 15 years 4 months ago

13 Answers:

Use Position-Type = FLOAT instead of FixRelativeToTop (=standard) to all the SubReports.

hth
C-Box
C-Box's picture
20609
Joined: Jul 19 2006 - 5:58pm
Last seen: 5 months 1 week ago
thx it helped
inditrozen's picture
Joined: Jan 26 2008 - 8:47am
Last seen: 15 years 4 months ago

Hi,

I encountered the same problem (overlapping subreport tables), but turning on the "positionType = float" didn't work.  I have copied the relevant code from my JRXML, and attached an example of the PDF that it's getting generated with the overlapping tables.

Are there other flags I should be checking to prevent the overlap? or am I making some obvious mistake?

FYI: I'm using JR version 3.0.0

Thanks in advance,

 

Ricardo Ulate

Code:
...
	<detail>
		<band height="2">
			<subreport>
				<reportElement positionType="Float" x="0" y="0" width="0" height="0"/>
				...
			</subreport>
			<subreport>
				<reportElement positionType="Float" x="0" y="1" width="0" height="0"/>
				...
			</subreport>
		</band>
	</detail>
...</td></tr></tbody></table>
rulate's picture
473
Joined: Sep 3 2008 - 10:52am
Last seen: 14 years 9 months ago
p.s. I forgot to mention, I know I can put the reports in different sections (e.g.: have one on the summary section). The example provided is a simple example, I plan to incorporate an arbitrary number of subreports into the report. Please try to keep the subreports in the same section when providing help or indicating if this is possible. Thanks once again!
rulate's picture
473
Joined: Sep 3 2008 - 10:52am
Last seen: 14 years 9 months ago
Code:
What is your fill direction of master report?
 
C-Box</td></tr></tbody></table>
C-Box's picture
20609
Joined: Jul 19 2006 - 5:58pm
Last seen: 5 months 1 week ago

Thanks for your quick response,

I direction fill value is vertical.  I'm ataching all the .jrxmls that generated this report (in case you want to check any additional information) and also highlighting in the code section below the relevant parts of these files to save you some time:

testME.jrxml   = parent
t0.jrxml            = child
t1.jrxml            = child

Regards,

 

Ricardo Ulate

Code:
==================================================
Relevant code from testME.jrxml:
==================================================
...
<jasperReport name="testME" pageWidth="595" pageHeight="842" columnWidth="555" leftMargin="20" rightMargin="20" topMargin="30" bottomMargin="30">
...
	<detail>
		<band height="2">
			<subreport>
			...
			</subreport>
			<subreport>
			...
			</subreport>
		</band>
	</detail>
...
</jasperReport>
 
 
==================================================
Relevant code from t0.jrxml:
==================================================
...
<jasperReport name="t0" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isFloatColumnFooter="true">
	<property name="adjustPageHeight" value="true"/>
	<property name="adjustPageWidth" value="true"/>
	...
	<columnHeader>
		<band>
			<frame>
				<reportElement positionType="Float" x="0" y="0" width="1026" height="0"/>
			...
			</frame>
		</band>
	</columnHeader>
	<detail>
		<band height="11">
			<frame>
				<reportElement positionType="Float" x="0" y="0" width="1026" height="11"/>
			...
			</frame>
		</band>
	</detail>
...
</jasperReport>
 
 
==================================================
Relevant code from t1.jrxml:
==================================================
...
<jasperReport name="t1" pageWidth="595" pageHeight="842" whenNoDataType="AllSectionsNoDetail" columnWidth="555" leftMargin="0" rightMargin="0" topMargin="0" bottomMargin="0" isFloatColumnFooter="true">
	<property name="adjustPageHeight" value="true"/>
	<property name="adjustPageWidth" value="true"/>
	...
	<columnHeader>
		<band>
			<frame>
				<reportElement positionType="Float" x="0" y="0" width="240" height="0"/>
			...
			</frame>
		</band>
	</columnHeader>
	<detail>
		<band height="11">
			<frame>
				<reportElement positionType="Float" x="0" y="0" width="240" height="11"/>
			...
			</frame>
		</band>
	</detail>
...
</jasperReport>
</td></tr></tbody></table>
rulate's picture
473
Joined: Sep 3 2008 - 10:52am
Last seen: 14 years 9 months ago

Hi --

This is just a shot in the dark.  I've never tried calling a subreport with height="0" before.

I notice the 2nd one starts at y="1".  What happens if you give each of them a height="1"?

 

Betty

itchytoes's picture
1987
Joined: Jan 12 2007 - 3:58am
Last seen: 16 years 4 months ago
Oops -- I meant just give the first one a height="1"
itchytoes's picture
1987
Joined: Jan 12 2007 - 3:58am
Last seen: 16 years 4 months ago

Setting the height to 1 of the sub reports did not work, but thanks for your suggestion.
 

rulate's picture
473
Joined: Sep 3 2008 - 10:52am
Last seen: 14 years 9 months ago

 

Hi,

I haven't heard back from anyone for a while with this issue.  Clearly, the setPositionType as Float property isn't working for me.  Would this be a bug? (if so, may I ask for a work around or a fix in a subsequent release?) or is this something I'm doing wrong?

Regards,

 

Ricardo

 

rulate's picture
473
Joined: Sep 3 2008 - 10:52am
Last seen: 14 years 9 months ago
You mention that you need an arbritatry number of subreports. How do you decide the no of subreports ?
shrije's picture
2343
Joined: Apr 5 2008 - 8:59am
Last seen: 9 years 2 months ago

shrije
Wrote:

You mention that you need an arbritatry number of subreports. How do you decide the no of subreports ?

My company requires a reporting tool that is very simple to use.  Every setting that can will have a default.  The page size will default to the letter page size (for easy printing) when selecting PDF, or will default to ignorePaginationWhen when selecting html.

A user will be able to add Report Components through a simple add method:

report = new Report ("output.pdf");

report.addImage("image.jpeg");

report.addTable("file.csv");

report.addTable("file2.csv");

report.generate();

The report components will be position one beneth the other.

 

As you can see, the number of tables in a report can vary according to the user's selection (each table is a sub report).  Most of this is implemented already and working correctly, but when a table is added, it overlaps with whatever comes after.

When using other report componets that grow in size (like crosstabs), the setPositionType Float works fine.

rulate's picture
473
Joined: Sep 3 2008 - 10:52am
Last seen: 14 years 9 months ago

Take a look at this link: http://stackoverflow.com/questions/353928/jasperreports-subreports-not-working-with-positiontype-float

For 2 subreports, it has to be done like this: set Position Type of the first one to "Fix Relative to Top". The second subreport has to be set to float. Also, the second subreports' "y" attribute must be equal to the first subreport "y" attribute plus the first subreport "height" attribute. Example:

 

<subreport>
                <reportElement x="38" y="38" width="347" height="1" isRemoveLineWhenBlank="true"/>
                <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{subreport1})]]></dataSourceExpression>
                <subreportExpression><![CDATA[$P{RemarkSubReport}]]></subreportExpression>
  </subreport>
  <subreport>
                <reportElement positionType="Float" mode="Opaque" x="38" y="39" width="480" height="1"  isRemoveLineWhenBlank="true" isPrintWhenDetailOverflows="true"/>
                <dataSourceExpression><![CDATA[new net.sf.jasperreports.engine.data.JRBeanCollectionDataSource($F{subreport2})]]></dataSourceExpression>
                <subreportExpression><![CDATA[$P{DetailSubReport}]]></subreportExpression>
</subreport

cardozodamian's picture
Joined: Jan 31 2012 - 8:00am
Last seen: 11 years 4 months ago
Feedback
randomness