Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to embed JasperReport sub-report into a jar

I have a jasper (master) report embed in a jar. The report is got from a java input stream. The jasper report is made by iReport 3.7.0

In this master report, there are a few sub-reports. At the moment I have to use

Subreport Expression : $P{SUBREPORT_DIR} + "\\SubReport.jasper"

Expression Class : java.lang.String

in the iReport to make it works. It means that I store the subReport.jasper in SUBREPORT_DIR folder.

My question is, how to embed these sub-reports in the jar like the master report? And what should fill in the "Default Value Expression"? (if it is needed)

The closest question and answer so far I have seen is in here

How to load subreport resources with Jasper?

However the answer is not sufficient to me for master report compile. There is an error message saying missing sub-report when compile (and this is why I think the Default Value Expression may be needed?)

Thank you very much!

like image 718
Mark09 Avatar asked Nov 10 '12 14:11

Mark09


People also ask

How do I add a page in Ireport?

To add a new page go to Ireport and "Add Report Group" ,by adding report group you can add as many pages you want. Save this answer. Show activity on this post. Save this answer.


1 Answers

for example: i have report and subreport, located in some *.jar file. to invoke subreport i set subreport expression

getClass().getResource("/path/to/my/report/in/a/jar/subreport.jasper").openStream()

and choose subreport expression class java.io.InputStream

it is working!

like image 142
y_scherbak Avatar answered Oct 11 '22 18:10

y_scherbak