Merge field switch error- can't use comma as thousand seperator

Hi All,

First time posting here. I’m using Aspose.Words for Java. In my template document, I put several merge fields for money type value. My merge field format looks like this:

MERGEFIELD Field_Name # #,###

It should produce 1,000 for the field in the generated report. But instead of having comma as thousand separator, it spitted out only 1000 without comma or period. When I changed the switch to 0,000 it produced 1000,000. But when I changed it to #.### it produced 1.000.

Is there anything wrong with my merge field switch or does it have something to do with Aspose or is it the problem with region/locale settings on my laptop? I’m in Indonesia, but I’ve changed my region setting to United States.

Thanks.
Raymon

Hi Laurentius,

Thanks for your inquiry. The number formatting (i.e. # #,###) you supplied to merge field is correct and worked perfectly on my side. The culture on my side was en-US. I think, it may be that your current culture is Indonesian. If this is found to be the case, please try using the following code snippet before executing MailMerge:

Document doc = new Document(@"C:\test\In.docx");
CultureInfo currentCulture = Thread.CurrentThread.CurrentCulture;
Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US"); 
doc.MailMerge.Execute();
Thread.CurrentThread.CurrentCulture = currentCulture;
doc.Save(@"C:\test\Out.docx");

I hope, this will help.

Best Regards,

Hi Hafeez,

Thanks for the reply. I guess it might be the problem. I’m using Aspose with Coldfusion. Do you have any sample code to set the culture in Coldfusion?

Thanks.

Hi

Thanks for your request. I am not professional in ColdFusion, but I think you can achieve this using its setting

Hope this helps.

Best regards,

Thanks all for the help. I did solved my problem though but I don’t know whether it’s the most feasible solution or not. I added these lines -Duser.language=en -Duser.region=US. in my Coldfusion Administrator java and jvm setting. Again thanks.

Hi Laurentius,

Thanks for your request. Firstly, it is perfect that you managed to resolve the issue. Secondly, yes, you can use this code for setting the default Locale via command line. Please let us know if you need more assistance, we will be glad to help you.

Best Regards,