Problem with Merge Field Formatting

Hello

I use Aspose. word 11.11

I wrote in word file MERGEFIELD UnitPrice # “$#,##0.00” * MERGEFORMAT as your sample file ProductCatalogDemo.doc.

I want to get the result as $10,000.35, but I got $100000,35000

Your example also does not work correctly.

Previously I was using version 6.6 and it worked correctly.

Help please

Thanks,

Mikhail

Hi Mikhail,

Thanks for your inquiry. I have tested the scenario and have not found any issue with output formatted value. Please find the input/output documents in attachment. It would be great if you please share your document with us for investigation purposes.

I have also tested the Product Catalog demo and it works fine. Could you please share some more detail about the issue which you are facing?

Document doc = new Document(MyDir + "Test06.docx");
doc.MailMerge.Execute(
new string[] { "UnitPrice" },
new object[] { "10000.35" });
doc.Save(MyDir + "AsposeOut.docx");

Hi.

I understood what the problem is.

In Russia, we use (or, rather, it is because Microsoft so decided) as decimal separator part use a comma, but in the English keyboard layout use a dot.

When I set in Regional settings as Decimal symbol - a dot, all start worked correct.

But I can’t set this at the all PC our clients this setting.

Please, correct this problems.

Because in version 6.6 all worked correct.

Thanks in advance

Mikhail

Hi Mikhail,

Thanks for sharing the details. I have tested the scenario with Russian Culture and have found the same issue. I have logged this issue as WORDSNET-7716 in our issue tracking system. I have linked this forum thread to the same issue and you will be notified via this forum thread once this issue is resolved. We apologize for your inconvenience.

popov_mikhail:

I want to get the result as $10,000.35

Please check the Russian number formatting from here. The output value should be $10 000,35 not as $10**,**000.35 (the value you described in your first post). Moreover, please check the attached output file generated with Aspose.Words 6.6 and let us know if you have any more queries.

Hi Mikhail,

Thanks for your patience. I have received response from our development team and like to share with you that the reported issue is not a bug. It is incorrect formatting according to Russian culture.

Please note that Aspose.Words tries to mimic the same behavior as MS Word do. If you do the mail merge with number formatting (# “$#,##0.00”) in MS Word, you will get the same output.

In your case, For “ru-RU” locale the number format should be “$# ##0,00” not “$#,##0.00”. Please correct the number formatting according to Russian culture in your document.

Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.

Hi.

I used your way ("$# ##0,00") and It have worked correct, but if i will execute my programm on computer with English culture, my programm will not work correct again.

Maybe there’s a way to make it work independent of culture?

Hi Mikhail,

Thanks for your inquiry. To control the culture used during field calculation, just set the Thread.CurrentThread.CurrentCulture property to a culture of your choice before invoking field calculation. Please read following documentation link for your kind reference.

https://docs.aspose.com/words/net/updating-and-removing-a-field/

Use the following code snippet for your requirement. Please let us know if you have any more queries.

Document doc = new Document(MyDir + "Test06.docx");
// Store the current culture so it can be set back once mail merge is complete.
CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
// Set to English language so dates and numbers are formatted using this culture during mail merge.
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
doc.MailMerge.Execute(
new string[] { "UnitPrice" },
new object[] { 10000.35 });
doc.Save(MyDir + "AsposeOut.docx");
// Restore the original culture.
Thread.CurrentThread.CurrentCulture = currentCulture;

The issues you have found earlier (filed as WORDSNET-7716) have been fixed in this .NET update and this Java update.


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