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

Free Support Forum - aspose.com

Multiple MailMerge with Datatables from stored procedures: very slow

Hi,

I use Aspose to fill a Word document, which contains multiple mergefields and loops like the loop example below.

«TD_AP_FE_FinEconCapacity»
«TableStart:FinEcCapacity»«LotTitle»
· «TableStart:FinEcCapacityLines»«FinEconCapacity»
«FinEconCapacityDetails»«TableEnd:FinEcCapacityLines»«TableEnd:FinEcCapacity»

For each loop in the template I have a stored procedure at database level which gives me the data. This data is inserted in a datatable (eg dt_x). So for each loop in the template I call the Execute method on my doc object.
e.g.

doc.MailMerge.Execute(dt_x); //dt_x = datatable which contains data of stored procedure x 
doc.MailMerge.Execute(dt_y); //dt_y = datatable which contains data of stored procedure y
doc.MailMerge.Execute(dt_z); //dt_z = datatable which contains data of stored procedure z

The problem is that these “Execute” lines of code or very slow…
What’s the best way to fill the template with data coming from different stored procedures?

Thanks in advance.

Regards,
Kim

Hi Kim,

Thanks for your inquiry. In this case, I would suggest you first build a DataSet and then make use of MailMerge.ExecuteWithRegions method. For more information, please read the following articles:

https://docs.aspose.com/words/net/types-of-mail-merge-operations/
https://reference.aspose.com/words/net/aspose.words.mailmerging/mailmerge/executewithregions/

I hope, this will help.

Best Regards,