In the example, formatting was applied to the object, and any expression located in the object. Everything worked correctly because there was only one expression in each object. However, if we have more than one expression and, they require different formatting, we can use inline formatting.
Using the example, resize the footer, it’s object and the objects text as shown below.
The total and number of orders will display in the object.:
When previewing both of the values are presented in monetary format (which we had previously set), which is incorrect:
To display each value correctly, they should be formatted individually. To accomplish this, we use format tags. They are added before the closing square bracket of the expression. For our example, disable the object formatting (select the “Text (without formatting)” category in the format editor). Now we need to modify the format of the first variable, since the second will definitely be displayed correctly (without formatting, i.e. as an integer, and this is what we need). Modify the object text in the following way:
Sum: [SUM(<Group."ItemsTotal">,MasterData1) #n%2,2m]
Preview, to make sure that the object displays correctly:
When using format tags, the general syntax is as follows:
Note that space between the expression and the “#” sign is mandatory! The tag itself might look as follows:
#nFormattingLine – the numerical format
#dFormattingLine – date/time format
#bFalse,True – boolean format
“FormattingLine” in every case is the argument to the function, by which formatting is accomplished. Thus, for numerical formatting, Delphi’s Format function is used, for date/time it is the FormatDateTime function. One can find the possible values from the Delphi help system. Below are several values used in FastReport:
for the numerical formatting:
%g – a number with the minimal signs number after decimal point
%2.2f – a number with the fixed number of signs after decimal point
%2.2n – a number with bits delimiter
%2.2m – a monetary format, accepted in the Windows OS, depending on the regional settings in the control panel.
for the date/time format:
dd.mm.yyyy – date of the 23.12.2003 type
dd mmm yyyy – date of the 23 Nov. 2003 type
dd mmmm yyyy – date of the 23 November 2003 type
hh:mm – time of the 23:12 type
hh:mm:ss – time of the 23:12:00 type
dd mmmm yyyy, hh:mm – time and date of the 23 November 2003, 23:12 type
It is acceptable to use a comma or dash instead of period in the line for the numerical format. This symbol will be used as a separator between the integer and the fractional parts of the value. Usage of other separators is not acceptable.
Formatting of the “#b” type (boolean), the formatting line is presented as two values separated by comma. The first value corresponds to “False,” the second one corresponds to “True.”
In order to avoid the necessity to memorize all these tags and their meanings, there is a convenient resource for formatting insertion in the “Text” object editor. When clicking the button, the format editor (which we have already examined) is called. After selecting a format, it is inserted to the text. Thus, if the cursor is placed before or after the closing square bracket, the format will be inserted correctly.