Mail Merge - Formatting MergeFields

I am using DocIO in ASP.Net Core to merge word documents from docx files created in Word (not template files created in code).

How do I format date and numeric fields.?

I've seen this post:

https://www.syncfusion.com/forums/116987/mailmerge-how-can-we-control-the-format-of-dates

The example given there is for a merge field created in code:

MERGEFIELD  Date \\@ "dd-MMM-yyyy"

Do I type exactly that into the Merge Field in Word? I've tried various things, e.g. remove the backslash, remove the backslash and @ symbol but I can't get a sequence that actual works. If I just have Date part then it prints the date ok. It's just the format that is the problem.

And would numbers also work in the same way? e.g. I am expecting to be able to just use 0.00 to print a number with two decimal places.


3 Replies

MJ Mohanaselvam Jothi Syncfusion Team June 29, 2018 01:06 PM UTC

Hi Jeff,

Thank you for contacting Syncfusion support.

To preserve Number (with two decimal places) and Date format in the merge field results, we suggest you to set formats in the field codes of merge field in the template Word document.

We suggest you to edit the field code in template Word document using Microsoft Word application by Right click on merge field -> Toggle Field codes . Then, set format (expected Number and Date format) in between field name and closing bracket of the field.

Please refer the below highlighted text in merge fields, which used to preserve formats after executing mail merge for the corresponding field in the document:

 
 



If the above solution doesn’t satisfies your requirement otherwise if you face any difficulties to set formats in your input Word document means, kindly provide us the template Word document (with dummy date)  which used at your end and the expected output results. Thereby, we will check and provide you the appropriate solution to meet your requirement at the earliest.


Please let us know if you have any other questions.

Regards,
Mohanaselvam J
 



JB Jeff Butterworth July 1, 2018 04:49 AM UTC

Thankyou. That did the trick!


MJ Mohanaselvam Jothi Syncfusion Team July 2, 2018 05:45 AM UTC

Hi Jeff,

Thank you for your update.

We are glad to know that our solution has resolved your issue. Please get back to us if you need any other assistance.
We will be happy to assist you as always.

Regards,
Mohanaselvam J
 


Loader.
Up arrow icon