Windows Regional Settings and Number Formatting in RDLC Reports
For Switzerland (de-CH), number formats in Windows are not correct regarding the thousands separator. It should be formatted “1’234,56” but is formatted like “1 234,56” (a space instead of an apostrophe).
Current status
Due to the nature of RDL and the option to specify a language name for each and every single TextBox Control, Report Viewer does not pick specific user changes for decimal or date formats, even if the requested regional setting is equal to the current user’s regional setting. Report Viewer retrieves the default culture settings for a language name, but does not take into account, that this setting (when selected as current/default user format) may have changed the number format.
So ReportViewer never knows about the current regional settings and the changed symbols when looking up and using the default settings. So for our friends from Switzerland, there is currently only one known option: manually change the thousands separator and re-format the RDLC decimal values. The drawback of this is that every decimal expression has to be changed in all affected reports.
Talking about the world and everything
Due to a talk between buildings K and L in Munich a while ago, we came across localization topics, globalization and ways to force specific locales (and number symbols) for a Windows Forms application. Unfortunately, there is no way, because globalization changes are only supported for web.config, not app.config. Not talking about different threads and (from my knowledge) no inheritance of culture information to the ReportViewer thread.
The end is near
With the Locale Builder tool, you can create custom locales with changed number symbols, build an MSI file of it, and the *REPLACE* an existing locale in Windows by assigning the same name to the new locale:
The new locale is installed using the MSI file, replaces the default locale (in this case for de-CH), and is marked with an asterisk as a custom locale:
Now, by default, the correct grouping symbol is used and shown when selecting de-CH, even without changing it manually:
With this in mind, what do you think is the result when a Report is executed on this system without any change? See fields VK-Preis (Sales Price) or Betrag (Amount).
However, when printing reports for foreign countries, it always uses the new default format now. Better than before, but not like a world champion would do…
So, in Object Designer, open table 8 Language in design mode and add the following function:
GetLanguageName(LanguageCode : Code[10]) : Text[10]
CultureInfo := CultureInfo.GetCultureInfo(GetLanguageID(LanguageCode));
EXIT(CultureInfo.Name);
Name | DataType | Subtype |
CultureInfo | DotNet | System.Globalization.CultureInfo.’mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ |
Save table 8.
Open report 206 in design mode and add a new column to the DataItem Sales Invoice Header:
Language.GetLanguageName(“Language Code”) Name: “LanguageName”
Now open the report layout for report 206 and bulk-select all TextBox controls in each Tablix. When selected, change the property Language for all controls to =Fields!LanguageName.Value.
Save everything and run report 206 for to show all posted invoices in the database. For all different languages, you should see correct decimal symbols.