Home End User
New Blog Posts: Merging Reports - Part 1 and Part 2

German Price Formatting

edited March 2009 in End User
Hi

We are trying to get prices to be formatted using the european/German style,
i.e. using commas instead of full stop (period). Because the document is
orinted using an English PC, we can;t just use the locale format.

I tried using the

$#,0,00;($#,0,00) displayformat but it messes up.

Any suggestions ?

Andy Dyble, Midsoft, andy.dyble@midsoft.com

Comments

  • edited March 2009
    Hi Andy,

    The Windows system settings (including the decimal separator) are stored as
    global variable in Delphi. One solution is to temporary override the global
    variables and then restore them back. Use a try..finally block. Another
    solution is to implement your own custom formatting class. See the following
    article.

    ---------------------------------------------
    Article: Currency Formatting in ReportBuilder
    ---------------------------------------------

    Currently when formatting currency display formats, ReportBuilder internally
    calls FloatToStrF with a ffCurrency paramter.

    This honors the Windows currency settings.

    There are two ways to override this behavior:


    1. Create a descendant of TppDisplayFormat.

    See ppDisplayFormat.pas. YOu can easily create a descendant of
    TppDisplayFormat and specify that your TmyDisplayFormat be used by
    ReportBuilder to perform formatting. See the initialization section
    ppDisplayFormat.pas.

    2. Override the Window currency values

    You can override this by setting Delphi's global variables for
    DecimalSeparator and CurrencyString. You will probably want to restore these
    values after printing the report.

    Below is a simple example:

    var
    lcSaveDecimalSeparator: Char;
    lsCurrencyString: String;

    begin

    lcSaveDecimalSeparator := DecimalSeparator;
    lsCurrencyString := CurrencyString;

    DecimalSeparator := '.';
    CurrencyString := '$';

    try
    Report.Print;
    finally

    DecimalSeparator := lcSaveDecimalSeparator;
    CurrencyString := lsCurrencyString;
    end;


    end;


    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
This discussion has been closed.