質問

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?

役に立ちましたか?

解決

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 here enter image description here

他のヒント

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.

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top