Jump to content

How to dynamically reorder subreports?


prosvet

Recommended Posts

Sorry if the a similar question was already answered, but I have not found the answer.

I have main report with many subreports that should be reordered at print time according to user preferences.

What is missing between ellipses (cf. code), are lines that would allow me to access subreports and whether change their source path, or move inside reportSource before compilation.

Thanks in advance

Igor

Code:

 



Post Edited by prosvet at 07/17/2012 15:45
Link to comment
Share on other sites

  • 3 weeks later...
  • Replies 1
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

 Finally, I have managed to do what I want. In case if someone later has the same problem, here's the code (just to give an idea):

Code:
String                  sourceLocation = "main_report_location"JasperDesign            reportSource   = JRXmlLoader.load(sourceLocation);JRDesignSubreport subReportDesign = null;JRExpression jrExpression = null;JRElement[] jrElements = ((JRDesignBand) reportSource.getDetailSection().getBands()[0]).getElements();for (JRElement jrElement : jrElements) {	if (jrElement instanceof JRDesignSubreport) {		subReportDesign = (JRDesignSubreport) jrElement;		jrExpression = subReportDesign.getExpression();		[...handle expression contents here...]		subReportDesign.setExpression();	}}ByteArrayOutputStream   reportOutStream   = new ByteArrayOutputStream();JasperCompileManager.compileReportToStream(reportSource, reportOutStream);returnStream = new ByteArrayInputStream(reportOutStream.toByteArray());
Link to comment
Share on other sites

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