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

Free Support Forum - aspose.com

How to perform MailMerge under specific Locale using Java

Hi all,

I am investigating the aspose words library there we are investigating the advantages in purchasing a license. While I am running a few examples the following problem occours.

DocumentBuilder db = DocumentBuilderFactory.newInstance().newDocumentBuilder();
org.w3c.dom.Document xmlData = … parse xml here …

Document doc = … read a word doc from file

xml_elt = “record” //define xml elt to use

doc.getMailMerge().execute(new XmlMailMergeDataTable(xmlData, xml_elt));

Now, the execute statement uses an XMLMailMergeDataTable (which implements IMailMergeDataSource) to get the values from an xml file and is provided as attachement.

However when I run the code to perform a mail merge on a document that was created with a different country setting then the setting for the JVM Locale I get the following error when using some specific formatting:

Caused by: java.lang.IllegalArgumentException: Malformed pattern “###.##0,00”
at java.text.DecimalFormat.applyPattern(Unknown Source)
at java.text.DecimalFormat.applyLocalizedPattern(Unknown Source)
at asposewobfuscated.li.a(PalFormatterCore.java:255)
at asposewobfuscated.lg.a(PalFormatter.java:582)
at com.aspose.words.ih.ce(DoubleConstant.java:123)
at com.aspose.words.asl.ce(StringConstant.java:29)
at com.aspose.words.ne.c(FieldFormatter.java:96)
at com.aspose.words.ne.a(FieldFormatter.java:27)
at com.aspose.words.oi.Jg(FieldUpdateActionApplyResult.java:74)
at com.aspose.words.oi.perform(FieldUpdateActionApplyResult.java:56)
at com.aspose.words.Field.a(Field.java:402)
at com.aspose.words.or.a(FieldUpdater.java:154)
at com.aspose.words.or.l(FieldUpdater.java:107)
at com.aspose.words.oo.execute(FieldUpdateExecutionItem.java:82)
at com.aspose.words.or.ho(FieldUpdater.java:97)
at com.aspose.words.or.a(FieldUpdater.java:73)
at com.aspose.words.yp.a(MailMergeRegion.java:297)
at com.aspose.words.yp.Vb(MailMergeRegion.java:273)
at com.aspose.words.yp.a(MailMergeRegion.java:71)
at com.aspose.words.MailMerge.execute(MailMerge.java:253)

Setting the default java Locale is not an option, so I would like to pass new Locale(“BE”) to the mail merge execute without setting the default Locale! can anyone help me with this please ?

Hi Christophe,

Thanks for your query. Please use the latest version of Aspose.Words for Java 11.0.0. If you still face problem then please share your document and XML data source for investigation purposes.

Hi there,

Thanks for your inquiry.

Also note that you can choose to use the
locale set for the merge field in your document using the FieldUpdateCultureSource property. This way you can set the appropriate language settings in the source document without being required to change the default locale for your application.

Please see this page for details: http://docs.aspose.com/display/wordsnet/How+to+Update+Fields