Free Support Forum - aspose.com

Issue in Merging date in AM/PM picture format

Received : 2007/09/17 06:46:10
Message : While trying to do merge region with a date field ({MERGEFIELD EventStartTime \@" MM/dd/yy h:mm AM/PM"}, AM/PM are being replaced with A9/P9 where 9 was the month.

if we use AM/PM as am/pm i.e. ({MERGEFIELD EventStartTime \@" MM/dd/yy h:mm am/pm"} then the merge happens correctly.


This message was posted using Aspose.Live 2 Forum

Hi

Thanks for your request. I have reproduced this problem and logged it into our defect database as issue # 3747. We will try to fix it in one of future releases. The notification will be posted here in this thread as soon as it will be done.

You can use workaround now. See the following code.

doc.Range.Replace(new Regex("AM/PM"), "am/pm");

string[] names = { "EventStartTime" };

object[] values = { DateTime.Now };

doc.MailMerge.Execute(names, values);

Best regards.

Actually i am a lil weary of using this option as it has two side effects:

1. My documents can be huge and in that case the replacement may have performance hit.

2. If in my document , I have AM/PM present other than in merge fields then this will also get replaced with am/pm.

Please suggest if there is a way to find the format of the merge field in ASPOSE.WORDS.

Also this requirement (AM/PM) is something of that we need to be addressed urgently so can u provide me with a hot fix or something for the same.

Hi

Thanks for your request. We will investigate whether and when it can be fixed. Please expect a reply before the next hotfix (within 2-3 weeks). We might just fix it by then or provide more information

Also you can try to use the following code as workaround.

//get all filds from document

NodeList fieldStarts = doc.SelectNodes("//FieldStart");

foreach (FieldStart mFieldStart in fieldStarts)

{

// get run that represents format.

Run fieldCode = (Run)mFieldStart.NextSibling.NextSibling.NextSibling;

//replace AM/PM with am/pm

fieldCode.Text = fieldCode.Text.Replace("AM/PM", "am/pm");

}

Best regards.

The issues you have found earlier (filed as 3747) have been fixed in this update.


This message was posted using Notification2Forum from Downloads module by aspose.notifier.