Index

JReport Formula

Formula Syntax

JReport formula syntax is a syntax with simple flow control and other statements. The large Formula Editor panel is the place where you write your formula statements. You should follow JReport formula syntax to write formulas.

In this syntax, sequence and selection control structure are supported. You can use it to control the execution of the statements. In this syntax, a parameter can be used as variable, and its value can be used in computation or making decisions. Since the value of the parameter is input before the report is run, the report can respond to the user input and generate different results.

Reference Note: If you want to define your own functions by using Java language, please refer to User's Guide | JReport Formulas.

Statements

The statement is the smallest executable unit in the syntax. A SQL procedure is a sequence of statements. Statements are separated by semicolon (;). There are many kinds of statements, such as declare statement, expression statement, assignment statement, if-else statement, return statement etc.

Expression

The expression is a combination of values, operators and functions, that produces a result. The value in the expression can be a literal value or a variable; 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:

Reference Notes: For detailed information about each data type, please refer to User Reference | Formula Syntax | Data Type.

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.

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, please refer to User Reference | Formula Syntax | Operators in this chapter.

Function

The function returns a value as the result. JReport formula syntax provides many built-in functions. Please refer to User Reference | Formula Syntax | Built-in Functions for detailed information about function.

Improving Performance When Special Fields are Used in Formulas

In JReport Designer, some special fields can be used in formulas, they are User Name, Print Date, Print Time, Fetch Date, Fetch Time, Modified Date, Modified Time, Record Number, and Page Number. All the referencable special fields are divided into two types according to the time their values are ready. The types are page level and constant level.

Page Level
The value of the special field will be ready at the time when the report result is generated. So the page-level special fields include: Fetch Date, Fetch Time, Record Number, and Page Number.

Constant Level
The value of the special field will be ready at any time before the engine runs. So the constant-level special fields include: User Name, Print Date, Print Time, Modified Date, and Modified Time.

In the previous versions of JReport Designer, as long as special fields are used in a formula, the formula is considered to be a page-level formula, and it will be calculated more than one time and filtered at the local machine. Therefore, the performance is slowed down. Now, the formula in which the constant-level special fields are used, is treated as constant-level formula, in this case, this formula will be calculated only one time, as a result, the performance is improved.

Index