We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Mailmerge Field Formatting

We recently did an upgrade from a very old aspose version ( 3.05 ) to version 10.5.
And now I'm having problems with the formatting of decimals with the mailmerge.

Culture: NL
Formatting picture: \# #0.00
Input: 1120,00

The output result with the old version: 1120,00
But the the new version: 1.120

What can I do to get the original result back.
Because the application is using a couple of hundred template files, I hope this can be done without changing the templates.

When I change the picture to \# #0,00 the result is oke.

Hi
Dirk,


Thanks for your inquiry. First of all, please note that by default Aspose.Words uses the culture of current thread which may affect the output of fields with format switches. But, I think, in your case, you can simply modify the number format switch by using the following code snippet:

Document
doc = new Document(@“C:\temp\test.docx”);

NodeCollection starts = doc.GetChildNodes(NodeType.FieldStart,
true);
foreach (FieldStart start in
starts)
{
if
(start.FieldType ==
FieldType.FieldMergeField)
{
Run
fieldCode = start.NextSibling
as Run;
fieldCode.Text =
fieldCode.Text.Replace(
"\# #0.00",
“\# #0,00”);
}
}

I hope, this will help.

Best Regards,

Hi,

Thanks for the swift reply. I will give your solution a try. Its a bit more complicated because the sample I gave is one of many different picture formats.

What I'm also interrested in is a general solution for this problem, so I can use the same format picture for other language settings. Ive seen many questions about the same subject but it's not clear to me. If its just a matter of culture settings, why is my code not working correctly?

Regards
Dirk Molman
Holland

Hi,


Thanks for your inquiry. Could you please attach your input document you are getting problems with here for testing? I will investigate the issue on my side and provide you more information. Also, please attach the target document i.e. generated by Aspose.Words v.3.05.

Moreover, for specifying the culture temporarily for MailMerge, please visit the following link:
<a href="https://forum.aspose.com/t/52258

Best Regards,