问题
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.
- 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 ...
来源:https://stackoverflow.com/questions/23082712/ireport-load-subreport-from-database