Jump to content
Changes to the Jaspersoft community edition download ×

Subreports not floating

Recommended Posts

By: Laurent Maillard - maillard

Subreports not floating

2003-05-28 00:09

I'm using 8 subreports within a main report, all written with the JasperReports API, each of them using his own datasource. The height of these subreports can vary according to the number of entry in their datasource. My problem is I can't get the subreports to float within the main report and be displayed one below another. On the contrary, they are covering each other.

This is the code I use to add each subreport to the main report (I use the 0.4.5 JasperReports distribution).


private synchronized void addSubreport(JasperDesign jasperDesign, JRDesignBand band, String name, int yPosition) throws JRException {


JRDesignParameter parameter = new JRDesignParameter();

parameter.setName(name + "Subreport");




parameter = new JRDesignParameter();

parameter.setName(name + "DataSource");




JRDesignSubreport subreport = new JRDesignSubreport();



//source subreport

JRDesignExpression expression = new JRDesignExpression();


expression.setText("$P{" + name + "Subreport}");



expression = new JRDesignExpression();


expression.setText("$P{" + name + "DataSource}");









For each subreport I use a greater value for the yPosition method parameter. Although I use the setPositionType() method, this makes no difference, the subreports don't float.

Am I missing something or is it a bug in JasperReports (since this code worked just well with version 0.4.2).


If anyone has an idea, I would really appreciate.









By: Teodor Danciu - teodord

RE: Subreports not floating

2003-05-28 00:24




Have you tried to make your subreport element at least

1 pixel wide as I already suggested you?




In order for them to float, they have to be at least 1 pixel

wide and to be placed one below de other, so that they

can push one another downwards when stretching.

If you subreport have zero width or if they do not align

on the verical axis, they do not float.


Thank you,







By: Laurent Maillard - maillard

RE: Subreports not floating

2003-05-28 00:39

Sorry for the double post, that wasn't intended. My subreports now float perfectly, thanks for the help.



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