Hi - I think this is relatively simple but am probably complicating it! Basically I want to merge an aspose data field into Word and change its format - the date is held in our database as 10/01/2010 but I want it to merge as 10 January 2010. I think this quite easily doable in word rather than Aspose (I’m more of an end user than an Aspose programmer), and hve the switch ( /@ DD MMM YYYY) figured out, but I can’t get Word to recoginse the merged Aspose field as a Word mrgefield. When I try to bookmark the Aspose merge field/ bookmark I get a null parameter error in our app. Any help at all would be really appreciated.
This message was posted using Aspose.Live 2 Forum
Hi
Thanks for your request. As I can see Aspose.Words recognizes date string perfectly. Here is code I used for testing. I also attached my input and output documents.
// Open template.
Document doc = new Document(@"Test001\in.doc");
// Execute mail merge.
doc.MailMerge.Execute(new string[]
{
"test"
}, new object[]
{
"10/01/2010"
});
// Save output document
doc.Save(@"Test001\out.doc");
I use the latest version of Aspose.Words for testing. You can download it from here:
https://releases.aspose.com/words/net
Best regards.
Hi,
We have a similar problem, I tried the docs attached and the date was not formatted in the output.A customer wants the date formatted without the time"04/10/2012
04:09", so they just want “04/10/2012” to appear in merged document. dd.MM.yyyy
I’ve attached a sample source file. I hope you can help with this issue. We have release our product with Aspose 11.1 (words for java).
From reading other posts this should be formatted without any extra coding on our side?
I build the IMailMergeDataSource from our data and call the Doc.getMailMerge().execute(mergeDataSource);
Do I need to do extra for this to work or can the customer fix up the fields in their template?
Thanks,Eamonn
Hi Eamonn,
Thanks for your inquiry.
I tested your scenario with the latest version of Aspose.Words i.e. 13.3.0 and was unable to reproduce any issue on my side. So, I would suggest you please upgrade to Aspose.Words 13.3.0. You can download it from the following link:
https://releases.aspose.com/words/net
You can also make use of FieldOptions.FieldUpdateCultureSource property to specify what culture to use to format the field result. Please note that by default, the culture of the current thread is used and this setting affects only date/time fields with \@ format switch.
For example, the following code snippet shows how to specify where the culture used for date formatting during field update and mail merge is chosen from.
// Set the culture used during field update to the culture used by the field.
doc.FieldOptions.FieldUpdateCultureSource = FieldUpdateCultureSource.FieldCode;
doc.MailMerge.Execute(new string[]
{
"quot_createddate"
}, new object[]
{
new DateTime(2011, 1, 01)
});
If we can help you with anything else, please feel free to ask.
Best regards,