Word Mergefield formatting switches

Hi guys –

I’ve been using the Word Mergefield formatting switches quite successfully for a long time with Aspose.Words. However, one of my users is from Germany and is reporting that it’s not working for him.

He’s trying this:

{ MERGEFIELD Amount # “#.##0,00 €” }

but the output for the field shows:

1900.00000

We’ve verified that his regional settings are for German/Germany.

All of the US-based formatting codes I’ve ever tried work great, so I’m a bit stumped as to what the problem is here. Thanks much for your suggestions.

I’ve attached the template and the output file for your review.

Mike

Hi
Thanks for your request. I have done some research and it seems that you should use the following mergefield code.
{ MERGEFIELD Price \# "0.00 €;" }
Also see the following link.
http://www.gmayor.com/formatting_word_fields.htm
Best regards.

Hi Vitaly –

No, that’s not right in this case, my friend. Your suggestion would be fine for using a decimal point (a “period”) to denote decimals. But that’s essentially the point of the problem. For my German user, he wants to use commas to denote cents, and periods to denote a thousands-separator.

For him, when my code passes a text string of “2500.25” to Aspose.Words, the output from the field needs to result in:

2.500,25 €

Including the semi-colon after the Euro symbol only denotes to Word that another formatting code (for negative values) will follow, so that would only be necessary if you include a formatting code for negative values.

To be thorough in my testing, I’ve tried this formatting code (but still, it doesn’t work correctly because Aspose.Words interprets the comma as a thousands-separator, not as an indicator for cents/decimals):

{ MERGEFIELD Price # “0,00 €;” }

Even according to the URL you provided (which I have practically memorized over the past year), when performing a merge with Microsoft Word, Word will detect the user’s Regional settings to understand whether to use periods or commas as separators. With Aspose.Words running on the server, I’m not sure how Aspose.Words understands how to use a comma instead of a period to denote decimals.

I hope this makes sense… Looking forward to more information.

I’ve explained the issue in more details here https://forum.aspose.com/c/words/8
Basically, you have to use “.” in the format switch, but the output will come out according to the culture settings on the machine (which you can also programmatically set using .NET functions).

Thanks very much for your message. Just to close this thread, I’ve solved the problem by using:

Thread.CurrentThread.CurrentCulture = new CultureInfo(UserLocale);

Works great!

The issues you have found earlier (filed as 711) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(12)