iReport:从数据库加载子报表 [英] iReport: Load Subreport From Database
本文介绍了iReport:从数据库加载子报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有使用子报表的报表,但是由于该子报表以BLOB
的形式存储在数据库表中,因此我无法在*.jrxml
文件中提供其路径(URL).有没有一种方法可以添加从数据库加载的*.jasper
文件(BLOB
或InputStream
)作为子报表.
I have report that uses a subreport, but since the subreport is stored in a database table as BLOB
, I cannot give its path (url) in the *.jrxml
file. Is there a way to add a *.jasper
file loaded from the database (BLOB
or InputStream
) as a subreport.
推荐答案
我知道了.
- 添加列表组件
- 在列表的数据集中获取字段,并将子报表保留为BLOB,将其称为
REPORT_DATA
. - 将
REPORT_DATA
字段的类型设置为InputStream
. - 在列表中添加子报表.
- 将子报表表达式"设置为
$F{REPORT_DATA}
及其表达式" 类"到InputStream
. - 相应地设置连接类型,表达式和参数.
- Add a list component
- In the list's dataset fetch the field you keep your subreport as a BLOB, lets call it
REPORT_DATA
. - Set
REPORT_DATA
field's type toInputStream
. - Add the subreport inside the list.
- Set "Subreport Expression" to
$F{REPORT_DATA}
and its "Expression Class" toInputStream
. - Set Connection type, expression, and parameters accordingly.
别忘了将列表组件的大小至少调整到子报表的大小,否则会出现类似:
Don't forget to resize the list component at least to the subreport's size, otherwise you get an error like :
net.sf.jasperreports.engine.design.JRValidationException: Band height validation for subreport ...
这篇关于iReport:从数据库加载子报表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文