2002 JI Open Discussion Posted August 18, 2006 Share Posted August 18, 2006 By: Laurent Maillard - maillard Subreports not floating 2003-05-27 06:42 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.setValueClass(java.io.File.class); jasperDesign.addParameter(parameter); parameter = new JRDesignParameter(); parameter.setName(name + "DataSource"); parameter.setValueClass(dori.jasper.engine.JRDataSource.class); jasperDesign.addParameter(parameter); JRDesignSubreport subreport = new JRDesignSubreport(); subreport.setY(yPosition); subreport.setHeight(35); //source subreport JRDesignExpression expression = new JRDesignExpression(); expression.setValueClass(java.io.File.class); expression.setText("$P{" + name + "Subreport}"); subreport.setExpression(expression); //datasource expression = new JRDesignExpression(); expression.setValueClass(dori.jasper.engine.JRDataSource.class); expression.setText("$P{" + name + "DataSource}"); subreport.setDataSourceExpression(expression); subreport.setPositionType(JRElement.POSITION_TYPE_FLOAT); subreport.setUsingCache(true); band.addElement(subreport); } 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. Thanks, Laurent By: Teodor Danciu - teodord RE: Subreports not floating 2003-05-27 07:24 Hi, Try to make your subreport elements at least 1 pixel wide. subreport.setWidth(1); I hope this helps. Teodor By: Laurent Maillard - maillard RE: Subreports not floating 2003-05-28 00:35 Great ! This worked perfectly. Thank you very much for your help Teodord. Laurent Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now