iReport Ultimate Guide - Nimsoft Library
iReport Ultimate Guide - Nimsoft Library iReport Ultimate Guide - Nimsoft Library
iReport Ultimate GuideThe vertical dimension is not important because, when you print the report, UR will use all the vertical spacenecessary, regardless of the element size (see Figure 10-12).3. Select the subreport element so that the property sheet shows its properties (Figure 10-13).Figure 10-13 Subreport properties4. We want to use the same database connection we used with the master report to populate the subreport, so set theconnection type to Use a connection expression. The expression will be just $P{REPORT_CONNECTION}.As explained, REPORT_CONNECTION is a built-in parameter holding a reference to the connection used in the report.5. Next, define the subreport expression; it is used by UR to locate the report that will be inserted as a subreport.Assuming the subreport Jasper file is in the classpath (from an iReport perspective it’s enough that it is in the samedirectory as the master report), the expression we’ll use is this:“subreport.jasper”6. Finally, since the subreport we are using requires the COUNTRY parameter, add a subreport parameter (by clicking on the ...button of the Parameters property). Click Add and set the subreport parameter name COUNTRY (the name must matchthe parameter name we defined in step step 3 on page 157); as expression for the value, we choose the field containingthe country name, that is, $F{SHIPCOUNTRY} (step step 3 on page 156).7. Preview the report. If everything has been done correctly, you should get a result like the one shown in Figure 10-14.160
SubreportsFigure 10-14 The final resultIn this example we created a basic report and subreport. The number of subreports that can be placed in a report is unlimited,and they can be used recursively, meaning that one subreport can contain other subreports. You can create very smallsubreports (only a textfield) and use them to lookup values, you can use a page layout with two subreports side by sideshowing two different lists of values, and so on.A last note. When you have several subreports one after the other, be sure you set the position type of the report element toFloat. In this way, you avoid the risk of overlapping the subreports when the space they require grows. Another suggestion isthat, when using subreports one after the other, place each subreport in a different band, splitting the Detail band using what’s161
- Page 109 and 110: Fields, Parameters, and VariablesTa
- 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: SubreportsFigure 10-11 Subreport Wi
- Page 163 and 164: Subreports3. Click the Add button t
- 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
SubreportsFigure 10-14 The final resultIn this example we created a basic report and subreport. The number of subreports that can be placed in a report is unlimited,and they can be used recursively, meaning that one subreport can contain other subreports. You can create very smallsubreports (only a textfield) and use them to lookup values, you can use a page layout with two subreports side by sideshowing two different lists of values, and so on.A last note. When you have several subreports one after the other, be sure you set the position type of the report element toFloat. In this way, you avoid the risk of overlapping the subreports when the space they require grows. Another suggestion isthat, when using subreports one after the other, place each subreport in a different band, splitting the Detail band using what’s161