iReport Ultimate Guide - Nimsoft Library

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

13.07.2015 Views

iReport Ultimate Guide16.2.2 Understanding MeasuresA measure is an object similar to a variable. It is always, in some way, the result of a calculation performed on a value for eachrow and column group that intersect a cell. Expressions for elements in a crosstab, such as print-when expressions andtextfield expressions, can only contain measures. In this context, you cannot use fields, variables, or parameters directly; youalways have to use a measure.To create a measure, right-click the measures node in the outline view and select Add Measure (see Figure 16-14). iReportadds the new measure to the outline view.Figure 16-14 Adding a measureJust as when you create a new group, you’ll need to define an expression for the measure. The easiest way to display a newmeasure is to use a textfield. Drag a textfield element into a cell and set the proper textfield expression (for example, with ameasure name like $V{Average_freight}) and the proper expression class for the textfield, which must be consistent withthe measure type.There are several options you can use to set a measure. Besides the name, class, and expression, you can set the calculationtype. If the available calculation types are not enough, you can provide a custom Incrementer class by means of a Factorythat returns an instance of that class (the factory must implement the interfacenet.sf.jasperreports.engine.fil.JRIncrementerFactory).Figure 16-15 Measure PropertiesIf you want to display your measure as a percentage of the grand total, you can set the property Percentage of type toGrand Total.Finally, you can specify a custom calculator class to perform the percentage calculation (the class must use the interfacenet.sf.jasperreports.crosstabs.fill.JRPercentageCalculator).16.3 Modifying Crosstab Element PropertiesTo see the crosstab properties in the property sheet, select the crosstab node in the outline view (see Figure 16-16).316

CrosstabsFigure 16-16 Crosstab PropertiesFollowing is a brief rundown of some of the options in this dialog box:Repeat Column HeadersRepeat Row HeadersColumn Break OffsetIf selected, the column headers will be printed on every page when the crosstabspans additional pages.If selected, the row headers will be printed on every page when the crosstab spansadditional pages.This specifies the space between two pieces of a crosstab when the crosstabexceeds the page width (see Figure 16-17).Figure 16-17 Column Break Offset16.4 Crosstab ParametersCrosstab parameters may be used in the expressions of elements displayed in the crosstab. They can be defined and managedthrough the outline view (see Figure 16-18).317

CrosstabsFigure 16-16 Crosstab PropertiesFollowing is a brief rundown of some of the options in this dialog box:Repeat Column HeadersRepeat Row HeadersColumn Break OffsetIf selected, the column headers will be printed on every page when the crosstabspans additional pages.If selected, the row headers will be printed on every page when the crosstab spansadditional pages.This specifies the space between two pieces of a crosstab when the crosstabexceeds the page width (see Figure 16-17).Figure 16-17 Column Break Offset16.4 Crosstab ParametersCrosstab parameters may be used in the expressions of elements displayed in the crosstab. They can be defined and managedthrough the outline view (see Figure 16-18).317

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

Saved successfully!

Ooh no, something went wrong!