how to pass jasper file path to subreport of subreport

前端 未结 4 1319
没有蜡笔的小新
没有蜡笔的小新 2020-12-03 16:30

I am using iReport tool in conjunction with JasperReports 1.3.4.

I have a master report, which contain two subreports. One of these subreports has an embedded subrep

相关标签:
4条回答
  • 2020-12-03 16:53

    I had the same issue and setting the SUBREPORT_DIR to the full package name containing my reports worked.

    For example:

    "com/mycomp/myapp/reports/"

    Our set ups are similar in that you have all reports in the same directory. The difference is I am running my app from the desktop (Java SE). However, my reports were located in a jar file. When I tried to set teh SUBREPORT_DIR to c:\path\to\app\myapp.jar!\com\mycomp\myapp\reports Jasper failed to locate the file.

    Hope this helps.

    0 讨论(0)
  • 2020-12-03 16:53

    As Marcio already explained, your SUBREPORT_DIR parameter has to be passed from the calling report to the subreport. Using relative path with .or ./ is not reliable, an absolute path is always to prefer.

    So you have to write in your jrxml file:

    <subreport isUsingCache="false">
        <subreportParameter name="SUBREPORT_DIR">
            <subreportParameterExpression><![CDATA[$P{SUBREPORT_DIR}]]></subreportParameterExpression>
        </subreportParameter>
        <subreportExpression class="java.lang.String"><![CDATA[$P{SUBREPORT_DIR} + "mySubreport.jasper"]]></subreportExpression>
    </subreport>
    

    You have to pass the subreportParameterExpression with the $P{SUBREPORT_DIR}, elswise it won't pass the parameters (only setting <subreportParameter name="SUBREPORT_DIR"/> is not enough).

    0 讨论(0)
  • 2020-12-03 17:04

    Click in Subreport1, go to the properties tab -> Subreport properties -> Parameters

    You will pass your 'MasterReport' SUBREPORT_DIR parameter as a parameter to 'Subreport1'. Create this entry:

    Name: SUBREPORT_DIR Expression: $P{SUBREPORT_DIR}

    Don't forget to recompile your reports and make sure to republish your web app in the application server.

    0 讨论(0)
  • 2020-12-03 17:05

    just set $P{SUBREPORT_DIR} as prompt and pass your value(the path to the directory may not be valid like c:\something.jasper instead of c:\\something.jasper)

    0 讨论(0)
提交回复
热议问题