Formatting Column Values Before Merge (Aspose.Words)

Hi All,

My question is in reference to Aspose.Words components.

Is there a way to format my column values (dates and numeric values) before the data gets populated/merged into the document.

OR

Is there a way to populate/merge individual field values rather than passing the dataset/data table to populate the entire document.

Because I don’t want my stored procedure to return the formatted values directly into my dataset/data table.

Thanks in advance

Narayanan Sankaranarayanan

Hi Narayanan,

Thank you for your interest in Aspose.Words.

Answer for both questions is yes.

It is possible to do custom preprocessing of merged data using MergeField event.

See https://reference.aspose.com/words/net/aspose.words.mailmerging/ifieldmergingcallback for more info on this.

It is also possible to merge individual field values using MailMerge.Execute(String[], Object[]) method overload.

More on this in https://docs.aspose.com/words/net/mail-merge-and-reporting/ article.

Best Regards,

Then how would this be for a repeating table?

I mean do you have a method with similar signature for ExecuteWithRegions.

Thanks

Narayanan Sankaranarayanan

ExecuteWithRegions does not have such overload because data source for a table should have a 2D structure by definition. You can always create and fill DataTable manually in code if you want to customize data source.

Would the MergeField event at least fire for repeating rows (ExecuteWithRegions)?

Thanks

Narayanan

Yes, MergeField will fire for each merged data item when doing ExecuteWithRegions.