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

Right-align currency: want to ignore ")"

edited January 2004 in General
When my report shows a column of currency numbers, and some are negative, I
want the decimal (or least sig dig) to line up, not the right edge. If I
change the display format by adding a space or an underscore, like this:
"$#,0.00_;$(#,0.00)", it thinks I want one more zero. What do I do?

Here's a sample:

$12345.67
$(12345.67)

Jeremy

Comments

  • edited January 2004
    Hi Jeremy,

    I believe the first option below will be the best for your situation.

    ---------------------------------------------
    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;



    For the end-user solution you may to code an event-handler
    for the Report.Template.OnLoadEnd event to setup the proper settings.

    --
    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited January 2004
    Nico, thanks, you've triggered a thought. For what I want, creating a
    descendant is alot of work. I can create a calced field, converting the
    numeric to a string. Non-negative numbers will have a space added at the
    end. Probably only works with a monospaced font, but I'm using courier-new
    anyway.

    Jeremy

This discussion has been closed.