如何将JasperReport子报告嵌入jar中 [英] How to embed JasperReport sub-report into a jar
问题描述
我在jar中嵌入了一个jasper(master)报告。报告来自java输入流。碧玉报告由iReport 3.7.0制作
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
子报告表达式:$ P {SUBREPORT_DIR} +\\SubReport.jasper
Subreport Expression : $P{SUBREPORT_DIR} + "\\SubReport.jasper"
表达式类:java.lang.String
Expression Class : java.lang.String
在iReport中使它工作。这意味着我将subReport.jasper存储在SUBREPORT_DIR文件夹中。
in the iReport to make it works. It means that I store the subReport.jasper in SUBREPORT_DIR folder.
我的问题是,如何将这些子报告嵌入jar中,就像主报告一样?什么应该填写默认值表达式? (如果需要的话)
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
< a href =https://stackoverflow.com/questions/4825726/how-to-load-subreport-resources-with-jasper>如何使用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?)
非常感谢!
推荐答案
例如:
我有报告和子报告,位于某些* .jar文件中。调用子报表我设置子报表表达式
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()
并选择子报表表达式类 java.io.InputStream
and choose subreport expression class java.io.InputStream
它正在运行!
这篇关于如何将JasperReport子报告嵌入jar中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!