Returning a value from Sub Report to Main Report in iReport

后端 未结 5 738
闹比i
闹比i 2020-12-09 12:39

Hi every one I am using iReports for generating one of the reports and stuck at one place.

The situation is like this:

I am using one sub report in my main r

相关标签:
5条回答
  • 2020-12-09 12:46

    Note, in earlier versions of JasperReports:

    When using a subreport returnValue, the variable returned must not be in the same band as the subreport itself.

    The affectation is done I think at the end of the rendering of the band.

    So add another band and use your variable inside.

    0 讨论(0)
  • 2020-12-09 12:47

    Although the question is already answered, I would like to highlight the importance of having calculation="System" on the variable in the Main Report (the report calling the SubReport).

    I wasted a lot of time before figuring this out...

    In the dummy-code for Main Report JRXML above, the variable "A" correctly has calculation="System". NB: The answer by @GenericJon covers the variable in the SubReport.

    0 讨论(0)
  • 2020-12-09 12:54

    i am agree with @bubba_hego99, the calculation type as below:

    system no caculation, just set as system, or valued as other operator.

    nothing no calulation, just set the variable.

    sum execute sum($Feild("A")).

    ....

    The detail you want to know other caculation, you should be to see the ireport document.

    0 讨论(0)
  • 2020-12-09 12:59

    From the JasperReports Ultimate Guide:

    The value coming from the subreport is available only when the whole band containing the subreport is printed. If you need to print this value using a textfield placed in the same band as your subreport, set the evaluation time of the textfield to Band

    0 讨论(0)
  • 2020-12-09 13:04

    In the subreport variable, you have calculation=System. This should be used when you are calculating the variable yourself using a scriptlet. You do not have an appropriate scriptlet attached to the report, so the variable is never being calculated.

    You probably want to change the variable definition so that it is calculated at the start of the subreport, something like this:

    <variable name="A" class="java.lang.Integer" resetType="Report" calculation="Nothing">
        <variableExpression><![CDATA[$F{sum}]]></variableExpression>
    </variable>
    

    resetType="Report" will never reset the variable while the report is running. calculation="Nothing" will evaluate the variableExpression for every row in the dataset.

    These attributes could be omitted though, as they are the default values used. You should then find that the variable is initialised correctly.

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