Hello
I wanted to create a new docx template with a number format.
I created a Mergefield a#0.00 to format the number with two decimal places. But my simply vanished.
Then I tried different formatting for fields with the same result. Even formatting with * Upper did not create the expected result.
Am I doing something wrong?
Here is my xml and docx:data.zip (9.7 KB)
If you want to round number to two decimal places and add a thousands separator, then please use the following switch in mail merge field:
MERGEFIELD a_Text \# "#,##.00"
Please see these template, output Word DOCX and XML data files (Resources.zip (18.8 KB)) and try running the following C# code of Aspose.Words for .NET API:
DataSet dataSet = new DataSet();
dataSet.ReadXml("C:\\temp\\data\\data.xml");
Document doc = new Document("C:\\temp\\data\\template.docx");
doc.MailMerge.ExecuteWithRegions(dataSet);
doc.Save("C:\\temp\\data\\20.11.docx");
Hello, I was stupid.
I tought I could add the format by right clicking a field, edit it, and putting the format behind the text in the ‘Field name’.
If I do it right my format also works.
Thank you.
It is great that you were able to find what you were looking for. Please let us know any time you may have any further queries in future.