One of the biggest features that formulas have is that you can use formulas to control the property values of objects at runtime. This provides you much more control, allowing you to customize your report and have flexibility to control the way objects are displayed based on the data values.
When you edit the property values of an object in the Report Inspector, you may notice that if you click some properties, there will be a button appearing on the right of the drop-down arrow, and when you click this button, it will change to be another button
and also the value cell will become empty. Then when you click the drop-down arrow, a drop-down menu will be listed. If you select one item in the list, the property will be controlled according to the return value of the formula. This is called conditional formatting in JReport.
Notes:
This example uses the formula MColor to control the Background property of the detail panel of a banded report at runtime. You can find this formula in the catalog SampleReports. The following is the content of the formula:
|
In this example we will vary the middle hexadecimal digits of the RGB color values. The Red value is fixed at 0x00, the Blue value is fixed at 0x7f. The Green value will change according to the number of records displayed. Record 1 will use color 0x00107f, Record 2 will use 0x00207f, and so on.
Take the following steps: