iReport Ultimate Guide - Nimsoft Library

iReport Ultimate Guide - Nimsoft Library iReport Ultimate Guide - Nimsoft Library

13.07.2015 Views

iReport Ultimate GuideWhen you execute the new report you should get a result similar to the one shown in Figure 16-7. The last column containsthe total for each row, across all columns. The last row contains the total for each column, across all rows. Finally, the last cell(in the corner on the bottom right) contains the combined total for all orders (830).16.2 Working with Columns, Rows, and MeasuresA crosstab must have at least one row group and one column group. The rows and columns are defined by these groups. Eachrow and column group can be totaled. The following is a basic crosstab with one column group and one row group; the groupsare totaled:Crosstabheader cellRow group1 headerRow group1totalheaderColumn group 1headerDetailColumn group 1 totalColumn group 1total headerRow group 1 totalGrand total (Row group 1 total+ Column group 1 total)When you add a row group, iReport adds the row with a header and subtotal for it.The crosstab appears as follows:Crosstabheader cellRow group1 headerRow group2 headerRowgroupstotalheaderColumn group 1headerDetailDetailColumn group 1 totalColumn group 1total headerRow group 1 totalRow group 2 totalGrand total (Row group 1 total+ Row group 2 total + Columngroup 1 total)Adding a column group results in a similar change, with a new column, header, and subtotal:Crosstabheader cellColumn group 1headerColumn group 2headerColumn groupstotal headerRow group1 headerRow group2 headerRowgroupstotalheaderDetail Detail Row group 1 totalDetail Detail Row group 2 totalColumn group 1 total Column group 2 total Grand total (Row group 1 total+ Row group 2 total + Columngroup 1 total + Column group 2total)312

CrosstabsFigure 16-8Adding a Row GroupRow and column groups are displayed in the outline view. To add a row group, for instance, right-click the rows node andselect Add Row Group (see Figure 16-8).The new group appears in the outline view and the relative cells are created in the crosstab designer. You need to set a BucketExpression—that’s an expression used to group the rows. For example, we can add a row group to show the cities of eachcountry. In that case, a valid expression could be the field SHIPCITY (the expression would look like $F{SHIPCITY}). Theexpression must be set in the row group properties.Figure 16-9The layout after the new rowThe expression is the only information that must be set for each new group. Other crosstab settings include the following:Total positionOrderComparator expressionDefines the presence of a row to show subtotalsOrder of the values in the group (Ascending or Descending)Returns an instance of java.util.Comparator that must be used toorder the valuesUsing the designer, column and row sizes can be modified directly by dragging the cells’ edges. The content of each cell mustbe completely contained in the cell (more or less as it happens with bands in the master report).313

<strong>iReport</strong> <strong>Ultimate</strong> <strong>Guide</strong>When you execute the new report you should get a result similar to the one shown in Figure 16-7. The last column containsthe total for each row, across all columns. The last row contains the total for each column, across all rows. Finally, the last cell(in the corner on the bottom right) contains the combined total for all orders (830).16.2 Working with Columns, Rows, and MeasuresA crosstab must have at least one row group and one column group. The rows and columns are defined by these groups. Eachrow and column group can be totaled. The following is a basic crosstab with one column group and one row group; the groupsare totaled:Crosstabheader cellRow group1 headerRow group1totalheaderColumn group 1headerDetailColumn group 1 totalColumn group 1total headerRow group 1 totalGrand total (Row group 1 total+ Column group 1 total)When you add a row group, <strong>iReport</strong> adds the row with a header and subtotal for it.The crosstab appears as follows:Crosstabheader cellRow group1 headerRow group2 headerRowgroupstotalheaderColumn group 1headerDetailDetailColumn group 1 totalColumn group 1total headerRow group 1 totalRow group 2 totalGrand total (Row group 1 total+ Row group 2 total + Columngroup 1 total)Adding a column group results in a similar change, with a new column, header, and subtotal:Crosstabheader cellColumn group 1headerColumn group 2headerColumn groupstotal headerRow group1 headerRow group2 headerRowgroupstotalheaderDetail Detail Row group 1 totalDetail Detail Row group 2 totalColumn group 1 total Column group 2 total Grand total (Row group 1 total+ Row group 2 total + Columngroup 1 total + Column group 2total)312

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!