iReport: Load Subreport From Database

邮差的信 提交于 2021-02-05 11:02:30

问题


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:


I figured it out.

  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 ...


来源:https://stackoverflow.com/questions/23082712/ireport-load-subreport-from-database

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!