iReport: Load Subreport From Database

后端 未结 1 783
臣服心动
臣服心动 2021-01-28 16:38

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

相关标签:
1条回答
  • 2021-01-28 16:54

    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 ...
    
    0 讨论(0)
提交回复
热议问题