Formulas
Formulas are objects that are computed at runtime, which allow you to manipulate field data by performing calculations on it. They control the data that will be displayed, and can even create new data not directly available from the database.
A formula is a symbolic statement of the manipulations that are to be performed on certain data before it is printed onto your report. For example, if your report contains an @Sales field and an @Cost field, and you want to create an @GrossProfit formula, you can designate its value as @Sales - @Cost. @GrossProfit is a simple formula that tells Logi JReport to subtract the value of the @Cost field from the value of the @Sales field, and then to print the result. Formulas can be used to calculate numeric values, compare one value to another and select alternative actions based on the comparison. Also, they can be used to join multiple text strings into a single string. In general, formulas can be used to:
- calculate information you cannot directly obtain from database data fields.
- compare data.
- join text with data.
- convert data from one form to another.
- enhance formatting options with text strings.
- do other things that customize your reports.
For more information about Logi JReport forumals, see the following topics:
For reports that use business views as the data source, you can also create dynamic formulas using resources available in the related business views to get the desired data.
See also:
- Formula Fields for how to work with formulas as component in a report.
- The report UsingFormula.cls in the SampleComponents catalog saved in
<install_root>\Demo\Reports\SampleComponents
which contains examples of how formulas could be used in a report.
Notes:
- You can only use JDK (not JRE) to compile formulas created in Logi JReport.
- Logi JReport formula searches for javac based on the java.home option, but this way may fail under some user environments. To ensure the formulas can work, you are recommended to use the javac_path option to specify the full path of javac yourself, for example, set
-Djavac_path=c:\jdk1.7.0_17\bin\javac.exe
in the startup file of Logi JReport.