iReport Ultimate Guide - Nimsoft Library
iReport Ultimate Guide - Nimsoft Library iReport Ultimate Guide - Nimsoft Library
iReport Ultimate Guide1. First, create a new empty report called master.jrxml. Let’s assume that the currently active connection points toJasperReports Sample database.2. Set the query as follow; it is designed to extract the names of countries, ordered by name:select distinct shipcountry from orders order by shipcountryIf iReport does not provide the data automatically, click Read Fields to get the fields from the query (Figure 10-5).Figure 10-5Selecting records for the master report3. The SHIPCOUNTRY field should appear in the outline view. Drag the field into the Detail band, adjusting the textfieldand font size (Figure 10-6).Figure 10-6SHIPCOUNTRY field in Detail band4. Test the report by clicking the Preview button. You should get something similar to Figure 10-7.156
SubreportsFigure 10-7Just a list of countriesNext, let’s start to create the report that will be used as the subreport. The subreport must have the following characteristics:• No margins (this is not mandatory, but of course we don’t need them).• No parameter to host the name of the country.• The width must be congruent with the space we want to reserve for it in the master report; let’s use the entire page widthminus the margins.• A set of textfields in the Detail band to show first and last name of each customer.1. Create a new empty report called subreport.jrxml (if you pick a different name, keep it in mind because we will use itwhen connecting the master to the subreport).2. Remove the page margins and adjust the page width (that is, an A4 page has a width of 595 pixels, subtracting 20 pixelsfor the left margin and 20 for the right one, the new page should be set to a width of 555 pixels with margins of 0).3. Add to this report a parameter that we’ll call COUNTRY.The type must be set to java.lang.String and the default value to a blank string (“”) or, if you prefer, to a countryname like “Argentina”. This default value will be overridden by whatever we specify from the master report. We areassigning it to the parameter now only because a default value in iReport (not in UR) is mandatory when usinga parameter inside a report query.4. Open the query dialog and enter the query to select the customer information based on the order’s country; it can besomething like this:select distinct shipname, shipcity from orders where shipcountry = $P{COUNTRY}157
- Page 105 and 106: Fields, Parameters, and VariablesRe
- Page 107 and 108: Fields, Parameters, and Variables6.
- 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: SubreportsFigure 10-4Subreport Para
- Page 159 and 160: SubreportsFigure 10-11 Subreport Wi
- Page 161 and 162: SubreportsFigure 10-14 The final re
- 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
<strong>iReport</strong> <strong>Ultimate</strong> <strong>Guide</strong>1. First, create a new empty report called master.jrxml. Let’s assume that the currently active connection points toJasperReports Sample database.2. Set the query as follow; it is designed to extract the names of countries, ordered by name:select distinct shipcountry from orders order by shipcountryIf <strong>iReport</strong> does not provide the data automatically, click Read Fields to get the fields from the query (Figure 10-5).Figure 10-5Selecting records for the master report3. The SHIPCOUNTRY field should appear in the outline view. Drag the field into the Detail band, adjusting the textfieldand font size (Figure 10-6).Figure 10-6SHIPCOUNTRY field in Detail band4. Test the report by clicking the Preview button. You should get something similar to Figure 10-7.156