views:

1623

answers:

1

Hello, I am so close to having this work, I am trying to directly embed one jasper subreport into the main report xml of the other. You'd think this would be easy, but I can't find a single example on doing it. Everyone seems to use files or resources or whatever. I have one report working straight from a string and I want it to contain it's subreport.

Anyone? Syntax? Thanks!

+2  A: 

The only way I know of to do this with JasperReports is to use a separate .jrxml file for the subreport, and include it in the main report using the subreport command.

Another option you have for any embedded reports is to use subdatasets, but as far as I know they're only useful for graphs.

As it sounds like you control the code surrounding the generation of the report, you could come up with a simple format to define multiple reports in the one string, and then have your code extract each report at runtime.

When we've needed to deal with a single file but have subreports for a JasperReport, we've used Zip files, and simply zipped up the main report and all it's necessary sub reports, and then unzipped them into a temporary directory when we need to (all in code of course)

Jamie Love
I have now indeed used the structure of my program to allow subreports as objects to be passed as parametsrs to another, and the dataSourceExpression of the subreport creates a "new JRBeanCollectionDataSource($P{SUBREPORT})"
Joshua