Expression

The expression is a combination of values, operators and functions that produce a result. The value in the expression can be a literal value or a variable, while the operator defines the operation between values; the function is used to perform an action and return a value.

Value

The value specified in an expression can be a literal value or a variable value. JReport formula syntax supports seven data types of value. See the section Data type for details.

Literal value

The Literal Value is a value that is used exactly as it is displayed. A literal value represents a value such as a Number, String, or Date. For example, "Name", 98.6...

Variables

A variable is a named storage unit used to store a value. The identifier (name) of variable can be used to refer to the value of the variable or refer to the storage space of the variable. In an expression, the identifier is used to refer to the value, and in assignment statement, the identifier on the left is used to refer to the storage space.

Report level global variable

To control the formula more flexibly, JReport offers you one more global variable scope to operate besides component level global variable. That is report level global variable. You can use "report" as the keyword to define the global variable in a formula.

For the two levels of global variable, the following definitions will help you distinguish them:

When using the keyword "global" to define a global variable in a formula, if you add no words before the keyword, the global variable is on the component level; if you add "report" before the keyword, the global variable will be a report level global variable.

Example

This example uses the report global variable to do a calculation in the report. First, create three formulas based on the report global variable as follows:

Formula1: report global number a =0;

Formula2: a = a+1;

Formula3: return a;

Then use them in one report set including two BandedObjects(BandedObject1 and BandedObject2) in the same dataset as follows:

  1. Insert Formula1, Formula2, Formula3 to the BandedObject1(15 records) as follows:

    BandedHeader:Formula1

    DetailPanel:Formula2

    BandedFooter:Formula3 - returns 15.

  2. Then insert Formula2 and Formula3 to the BandedObject2(25 records) as follows:

    DetailPanel:Formula2 

    BandedFooter:Formula3 - returns 40.

Notes:

Operator

An operator is a symbol that indicates an operation to be performed on values. The JReport procedure language has several classes of operators, including math, comparison and logical operators. For detailed information about operator, see the section Operators in this chapter.

Function

Functions return a value as its result. JReport formula syntax provides many built-in functions. You can refer to the section Built-in functions for detailed information about function.