1
votes

In FastReport, I want to change the format of a field that holds currency values.

Right now it uses the format %2.2n, which shows numbers as 1,234.50. I want to change this to 1.234,50 but can't seem to find a format in the Delphi documentation that would do this for me. Does a format with this purpose exist or do I have to build a whole new field using FormatFloat?

3
I don't know FastReport, but if it were me I would start by testing its behaviour with different locale settings firstHugh Jones
@HughJones I need to generate reports for different countries, so changing locale settings would not be practical at all.user2244255
My suggestion was to test it to gain understandingHugh Jones

3 Answers

8
votes

You are not limited to the defaults you can use FormatStr e.g with $ ###0.00 and change DecimalSeparator and ThousandSeparator as you like.

enter image description hereenter image description here

4
votes

FastReport documentation on numerical formatting is as follows :

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

If the report is generated by the client then it's best to set it as 2.2m but if you're generating it yourself and submitting it to the client then you'll have to go for an alternative.

1
votes

Before launching your report invoke SetThreadLocale() and GetFormatSettings() to the appropriate country code and allow the operating system to do the rest.