Hello team, I have code running like below since 2007. Changing the culture of the thread to Invariant then was the way to go to have a consistent culture and working numeric formats on each machine. The goal was to always have numeric format having a comma as decimal separator. The worked by setting the NumberDecimalSeparator. Users always use the format "= 20000 \# 0.00"
which results in 20000,00.
This format is therefore embedded in a great number of user-defined word layouts, so I have to be careful not to change that behaviour.
The problem now is that I need to make the thousands separator visible, like 20.000,00
I cannot seem to get that to work without changing the culture to dutch, for example. If I would do that I think all existing layouts (that use "= 20000 \# 0.00"
) will not work consistently anymore.
With my invariantculture with NumberDecimalSeparator = ","
"= 20000 \# #.##0,00"
gives this result “20000, 0.00”
CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
CultureInfo tempCulture = (CultureInfo)CultureInfo.InvariantCulture.Clone();
tempCulture.NumberFormat.NumberDecimalSeparator = ",";
Thread.CurrentThread.CurrentCulture = tempCulture;
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);
{
Field field = builder.InsertField(@"= 20000 \# 0.00");
field.Result.Dump(); // result is 20000,00
}
{
Field field = builder.InsertField(@"= 20000 \# #.##0,00");
field.Result.Dump(); // result is 20000, 0.00
}
Thread.CurrentThread.CurrentCulture = currentCulture;
Would you have some advice for this? Setting the currencygroupseparator to ‘.’ does not have a good result.
I am using version 19.9.
Thanks, Ed