iReport Ultimate Guide - Nimsoft Library
iReport Ultimate Guide - Nimsoft Library iReport Ultimate Guide - Nimsoft Library
iReport Ultimate Guidecalled a “fake group.” This is a group having as expression, for instance, the REPORT_COUNT parameter, which ensures thatyou will get the fake group header and footer bands for each detail. In this way, you will optimize the report generation.10.3 Returning Values from a SubreportIn a report, it is often useful to get the result of some kind of calculation that has been performed in a subreport (for instance,the number of records).UR provides a feature that allows users to retrieve values from within a subreport. This mechanism works much thesame as passing input parameters to subreports. The idea is to save values calculated during the filling of the subreport intovariables in the master report.Bindings between calculated values and local variables can be set in the Subreport Return Values property in the propertysheet.Let’s see how to use it with the sample we created in the previous section. Suppose we want to print in the master report thenumber of cities we have found for each country. From the subreport perspective, this value is represented by theREPORT_COUNT variable, which is not accessible directly from the master report. So the first step is to create a variable to hostthis value at the end of the subreport elaboration. The variable must be consistent with the value it will host. In this case, it isan integer.1. In the master report, create a new variable (let’s call it SUBREPORT_COUNT) that is type java.lang.Integer andcalculation type System.2. Select the subreport element and open the Return Values property dialog by clicking the appropriate ... button(Figure 10-15).Figure 10-15 Subreport Return Values162
Subreports3. Click the Add button to create the new return value; the Add/Modify variable dialog will appear (Figure 10-16):Figure 10-16 The Subreport Return Value Definition dialog4. Select a calculated value from the subreport’s built-in variables (REPORT_COUNT), as well as the local variable that willcontain the values returned by the variable (SUBREPORT_COUNT).5. Next, select a calculation type.If you want a subreport value to be returned as-is, select the type Nothing. Otherwise, several calculation types can beselected. For example, if the desired value is the average of the number of records within a subreport that is invokedrepeatedly, set the calculation type to Average.In your master report, when you created a new variable to be used like a container for a returned value, you set thevariable calculation type to System. The effective calculation type performed on the variable values is the onedefined in the dialog box shown in Figure 10-16.The value coming from the subreport is available only when the whole band containing the subreport is printed. If you need toprint this value using a textfield placed in the same band as your subreport, set the evaluation time of the textfield to Band(Figure 10-17).Figure 10-17 A textfield showing the return value (with evaluation time set to Band)The report preview should look like the one in Figure 10-18.163
- Page 111 and 112: Bands and GroupsCHAPTER 7BANDS AND
- Page 113 and 114: Bands and Groupsexpression may be r
- Page 115 and 116: Bands and GroupsFigure 7-6Dragging
- Page 117 and 118: Bands and GroupsFigure 7-10The firs
- Page 119 and 120: Bands and GroupsFigure 7-14 shows t
- Page 121 and 122: 7.3 Other Group OptionsBands and Gr
- Page 123 and 124: Fonts and StylesCHAPTER 8FONTS AND
- Page 125 and 126: Fonts and StylesThe list of availab
- Page 127 and 128: Fonts and StylesFigure 8-5Font Exte
- Page 129 and 130: Fonts and StylesFigure 8-7Font Exte
- Page 131 and 132: Fonts and StylesFigure 8-10The new
- Page 133 and 134: Fonts and StylesTo apply a style to
- Page 135 and 136: Fonts and StylesFigure 8-17The outl
- Page 137 and 138: TemplatesCHAPTER 9TEMPLATESOne of t
- Page 139 and 140: TemplatesFigure 9-2Columnar reportA
- Page 141 and 142: TemplatesFigure 9-4Group by step in
- Page 143 and 144: TemplatesIf a static text element i
- Page 145 and 146: TemplatesFigure 9-8Your custom temp
- Page 147 and 148: TemplatesFigure 9-10New template in
- Page 149 and 150: TemplatesFigure 9-12Preview of repo
- Page 151 and 152: SubreportsCHAPTER 10 SUBREPORTSSubr
- Page 153 and 154: SubreportsFigure 10-3Subreport elem
- Page 155 and 156: SubreportsFigure 10-4Subreport Para
- Page 157 and 158: SubreportsFigure 10-7Just a list of
- Page 159 and 160: SubreportsFigure 10-11 Subreport Wi
- Page 161: SubreportsFigure 10-14 The final re
- Page 165 and 166: Subreports10.4 Using the Subreport
- Page 167 and 168: SubreportsFigure 10-21 Subreport co
- Page 169 and 170: SubreportsFigure 10-23 Setting Subr
- Page 171 and 172: Data Sources and Query ExecutersCHA
- Page 173 and 174: Data Sources and Query Executers•
- Page 175 and 176: Data Sources and Query ExecutersFig
- Page 177 and 178: Data Sources and Query ExecutersFig
- Page 179 and 180: Data Sources and Query ExecutersFig
- Page 181 and 182: Data Sources and Query ExecutersFig
- Page 183 and 184: Data Sources and Query ExecutersFig
- Page 185 and 186: Data Sources and Query ExecutersFig
- Page 187 and 188: Data Sources and Query Executers•
- Page 189 and 190: Data Sources and Query ExecutersAft
- Page 191 and 192: Data Sources and Query ExecutersIns
- Page 193 and 194: Data Sources and Query Executerspub
- Page 195 and 196: Data Sources and Query ExecutersFig
- Page 197 and 198: Data Sources and Query ExecutersFig
- Page 199 and 200: Data Sources and Query Executersbe
- Page 201 and 202: Data Sources and Query ExecutersFig
- Page 203 and 204: Data Sources and Query ExecutersWhe
- Page 205 and 206: Data Sources and Query ExecutersCod
- Page 207 and 208: Data Sources and Query ExecutersPre
- Page 209 and 210: Data Sources and Query ExecutersFig
- Page 211 and 212: Data Sources and Query Executersspe
Subreports3. Click the Add button to create the new return value; the Add/Modify variable dialog will appear (Figure 10-16):Figure 10-16 The Subreport Return Value Definition dialog4. Select a calculated value from the subreport’s built-in variables (REPORT_COUNT), as well as the local variable that willcontain the values returned by the variable (SUBREPORT_COUNT).5. Next, select a calculation type.If you want a subreport value to be returned as-is, select the type Nothing. Otherwise, several calculation types can beselected. For example, if the desired value is the average of the number of records within a subreport that is invokedrepeatedly, set the calculation type to Average.In your master report, when you created a new variable to be used like a container for a returned value, you set thevariable calculation type to System. The effective calculation type performed on the variable values is the onedefined in the dialog box shown in Figure 10-16.The value coming from the subreport is available only when the whole band containing the subreport is printed. If you need toprint this value using a textfield placed in the same band as your subreport, set the evaluation time of the textfield to Band(Figure 10-17).Figure 10-17 A textfield showing the return value (with evaluation time set to Band)The report preview should look like the one in Figure 10-18.163