Menu

Display of numbers in Report (Number Format)

Peter Pahn
2017-09-11
2017-09-12
  • Peter Pahn

    Peter Pahn - 2017-09-11

    Hi Michael,

    We are facing some issues ragarding number values in the report.

    Numbers (with 2 numbers after the decimal point) are displayed without decimal seperator in the report.
    ==> 2,45 wil be displayed as 245

    The format of the XML data source is set to: java.math.BigDecimal but it does not work.

    If we just set the data type to string it shows correctly but it's hard to have conditional styles implemented.

    Also, how can we configure how the decimal setting is used (e.g. English / German) ?

    Thanks

     
  • Michael

    Michael - 2017-09-12

    Hi Peter,

    first thing you have to know how your number are serialized into the data XML.
    I.e. you have to know is the decimal separator a dot (US style) or a comma (German style) etc.
    In your Report Query in APEX you can achieve a specific number format with the to_char function.
    For example to use a dot:

    select to_char(my_number_col, '99999999999.09999999'), ...
    from   ...
    

    Now to tell JR PrintServer how to transform the strings from the data XML for your fields that have a Java number type (i.e. BigDecimal), you have to specify the correct "xmlLocale" in your Report Template. (See the wiki page https://sourceforge.net/p/jrprintserver/wiki/APEX%20Report%20Layouts%20for%20the%20JR%20PrintServer/).

    In this case (dot) we should specify en_US. (This is also the default, if you don't specify this.)

    This should allow the correct data type conversion from the string contents of the data XML into Java number data types (this controlled by the settings xmlLocale and numberFormat in the Report Template).

    How you want to display Fields values inside your report is controlled by the "reportLocale" setting (this may differ from the xmlLocale setting).
    This way you could have your number in US style (xmlLocale = en_US) inside the XML, but display them in your report nicely (with Java number formats) in German style (reportLocale = de_DE).

    Regards,
    Michael

     

Log in to post a comment.

MongoDB Logo MongoDB