Inline formatting

Top  Previous  Next

Inline formatting allows you to set different formatting for each expression contained in the object. It was used in previous versions of FastReport. Now it is obsolete (use the formatting dialogue to set different formatting for each expression).


Using the example, re-size the footer and its object and change the object text to this:


Total: [SUM(<Group."ItemsTotal">,MasterData1)]

Number: [COUNT(MasterData1)]


The total and the number of orders will be displayed in the object.


In the report preview both of these values are shown in monetary format, which we had previously set. This is incorrect:




To display each value in its correct format they need to be formatted individually. To do this we use format tags, which are placed just before the closing square bracket of the expression. In our example, disable formatting for the object (select “Text (no formatting)” category in the format editor). Now we need to specify the format for just the first expression, as the second one will be displayed correctly by default (i.e. as an integer). Change the object text as follows:


Sum: [SUM(<Group."ItemsTotal">,MasterData1) #n%2,2m]

Number: [COUNT(MasterData1)]


Preview the report to make sure that the object is displayed correctly:




The general syntax of format tags is:


[expression #formattag]


Note that the space character between the expression and the “#” symbol is mandatory! The format tag itself might look like:


#nformat_string – numerical format

#dformat_string – date/time format

#bFalse,True – boolean format


Format_string in each case is the argument to the function used for formatting. So, for numerical formatting the Delphi Format function is used, and for date/time the FormatDateTime function. The syntax for these functions can be found in the Delphi help system. Below are several values used in FastReport:


for numerical formatting:

%g – number with the minimal places after the decimal point

%2.2f – number with a fixed number of places after the decimal point

%2.2n – as previous, but with thousands separator

%2.2m – monetary format, accepted by the Windows OS, dependent on the regional settings in the control panel


for date/time formatting: – date as '23.12.2003'

dd mmm yyyy – date as '23 Nov 2003'

dd mmmm yyyy – date as '23 November 2003'

hh:mm – time as '23:12'

hh:mm:ss – time as '23:12:00'

dd mmmm yyyy, hh:mm – date and time as '23 November 2003, 23:12'


A comma or a dash can be used instead of the dot in the format_string for numerical formatting. This symbol is used as the separator between the integer and the fractional parts of the value. Any other character is not allowed.


For formatting with the “#b” type (boolean), the format_string is entered as two values separated by a comma. The first value corresponds to “False” and the second to “True”.