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

Free Support Forum - aspose.com

Merge Feild Date formatting

Hi,

We are using aspose.words version 15.10.0.0. I am trying to use merge field customization and it does not seem honor the custom formatting. For example I have a merge field called dateCreated and I tried below merge field formatting but it is not honoring it

{MERGEFIELD dateCreated .@ “dddd, d MMMM yyyy”}
{MERGEFIELD dateCreated . @ “ddd, d MMMM yyyy”}
{MERGEFIELD dateCreated .@ “. @ “d MMM yyyy””}

Is there any existing bug with the aspose version we are using or is there any wrong with the merge field format that am using.

Thank you very much
Hi there,

Thanks for your inquiry. Please use FieldOptions.FieldUpdateCultureSource property to specify what culture to use to format the field result. In your case, we suggest you please use FieldUpdateCultureSource.FieldCode as shown below. Hope this helps you.

// Set the culture used during field update to the culture used by the field.

doc.FieldOptions.FieldUpdateCultureSource = FieldUpdateCultureSource.FieldCode;

doc.MailMerge.Execute(new string[] { "dateCreated" }, new object[] { new DateTime(2016, 1, 01) });