In "old good classic" NAV we have feature (and property) named AutoFormatType. Together with property AutoFormatExpr we can set decimal to any format we need.
This could be done in the way: we describe new AutoFormatType in the codeunit 1 in function "AutoFormatTranslate(AutoFormatType : Integer;AutoFormatExpr : Text) : Text)"
For example I can describe that i want to have decimal in the way 1 234 567,89 and doesn't matter what regional settings i have, or i want to format decimal depending on "customer on sales invoice" language but without changes regional settings.
So this works in Classic Client reports but it doesn't in RDL, because RDL format decimals according regional settings or if say more precisely: according .NET culture settings.
But what to do if we want to format decimal on the same report regarding some national rules?
We want to have:
1 234 567,89
in ReportLayout design we can find that every Textbox has property named Language. Value could be: Default, Afrikaans,Afrikaans (South Africa) and etc. So if we for example set Language = French, then decimal will be 1 234 567,89; if Language=German (Germany) - number will be 1.234.567,89, if Language=English (United States) - number 1,234,567.89 and etc.
But this is "hardcode" language set. What if we want to set language dynamically? Lets say i want to set report language in request page and choose between: Default; English (US), German, French formats.
Then I open report in report designer and created variable "OptLang" type option and OptionString is Default,English (US),German (Germany),French.
Add this variable to Request page:
And in the sections I add textbox which SourceExp=OptLang and DataSetFieldName = Lang. Dont forget to set this textbox Visible=No as we need this textbox only to transfer value to RDL report.
Now in the RDL reportlayout we see datafield "Lang" in DataSet. It value could be the same as we set in option string, but ATTENTION: we can't directly fill this value to property Language. This property accepts only values as it are described in http://msdn.microsoft.com/en-us/goglobal/bb896001.aspx. So it is French we need to assign "fr-FR"; is English (US) then "en-US"; if German (Germany) then "de-DE"
Easest way to do that is to create new public Function in report properties code. This function returns correct value depending on value we send to it.
Now return to RDL sections, select whole row (or all textboxes) and in language parameter write in expression: =code.SetLang(Fields!Lang.Value)
Now save and compile everything.
Run report from RTC.
In open request page chose language you want and preview report.
You see that now decimals are displayed with separators we want.
That is all what i want to show.
BTW: how number will be displayed you can set in Format property by describing string like it is described at http://msdn.microsoft.com/en-us/library/dwhawy9k(v=VS.95).aspx
Special thanks to Claus and Roman 🙂
These postings are provided "AS IS" with no warranties and confer no rights. You assume all risk for your use.
Microsoft Customer Service and Support (CSS) EMEA