iReport:从数据库加载子报表 [英] iReport: Load Subreport From Database

查看:92
本文介绍了iReport:从数据库加载子报表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有使用子报表的报表,但是由于该子报表以BLOB的形式存储在数据库表中,因此我无法在*.jrxml文件中提供其路径(URL).有没有一种方法可以添加从数据库加载的*.jasper文件(BLOBInputStream)作为子报表.

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.

推荐答案

我知道了.

  1. 添加列表组件
  2. 在列表的数据集中获取字段,并将子报表保留为BLOB,将其称为 REPORT_DATA.
  3. REPORT_DATA字段的类型设置为InputStream.
  4. 在列表中添加子报表.
  5. 将子报表表达式"设置为$F{REPORT_DATA}及其表达式" 类"到InputStream.
  6. 相应地设置连接类型,表达式和参数.
  1. Add a list component
  2. In the list's dataset fetch the field you keep your subreport as a BLOB, lets call it REPORT_DATA.
  3. Set REPORT_DATA field's type to InputStream.
  4. Add the subreport inside the list.
  5. Set "Subreport Expression" to $F{REPORT_DATA} and its "Expression Class" to InputStream.
  6. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆