Insert table (DataTable) in a Field position

Hello,

1.- I'd like to know if it is possible to have, among the information contained in the Merge fields, one (or several) that includes a table (datatable).
My intention is to use MailMerge so that a document can have multiple fields. Some will have data (strings) and some may have tables.

2.- Also, is it possible to know the position of a certain merge field within the document? The idea is to be able, at any time before performing the Merge, to detect it and, if necessary, replace it (by a table, for example).

Thanks in advance.

3 Replies 1 reply marked as answer

SM Suriya Murugan Syncfusion Team March 26, 2021 03:23 AM UTC

Hi Alfredo, 

Thank you for contacting Syncfusion support.

Regarding I'd like to know if it is possible to have, among the information contained in the Merge fields, one (or several) that includes a table (datatable).
 
My intention is to use MailMerge so that a document can have multiple fields. Some will have data (strings) and some may have tables.

 

From the details, we have found that your requirement is to perform mail merge using string values and data table.
If you wish to use string array as data source, we suggest you to refer the below UG documentation to achieve your requirement
 

https://help.syncfusion.com/file-formats/docio/mail-merge/simple-mail-merge#execute-mail-merge

If you wish to use data table, we suggest you to refer the below UG documentation to achieve your requirement
 


Regarding Also, is it possible to know the position of a certain merge field within the document? The idea is to be able, at any time before performing the Merge, to detect it and, if necessary, replace it (by a table, for example).
 


We have prepared the sample application to achieve your requirement. We suggest you use the below sample application at your end to replace the certain field with table.
https://www.syncfusion.com/downloads/support/forum/163823/ze/DocIOApplication-772308082

In the above sample, we have done the following things
 
 
1.      Loads the template Word document 
2.      Create the table to replace with field 
3.      Give the merge field which you want to replace 
4.      Iterate the elements in the document 
5.      Replace the merge field with table 
6.      Saves the Word document 
7.       

Please refer the below links to know more about how to work with mail merge using DocIO
 
 

Please let us know if you have any other questions.
 

Regards, 
Suriya M. 


Marked as answer

AS Alfredo Simancas March 26, 2021 09:18 PM UTC

Hello Suriya, thank you very much for the example code, is quite clear.

Regarding my question Number 1, what I was trying is to directly substitute a field with a table using mail merge (this table/field will be associated with a data table in the data source). Seems to me that mail merge for group is intended to create tables rows from several fields.  
The data I want to use in the mail merge will have fields associated with strings, images, data tables, and so on.

In simple words, I was asking if the mail merge feature would do exactly what you have done programmatically in the example code. Does that capability exist?

Best Regards,

Alfredo



SM Suriya Murugan Syncfusion Team March 29, 2021 06:31 AM UTC

Hi Alfredo, 

Syncfusion Greetings! 

We couldn’t achieve your requirement of replacing field with table using Merge field functionality. Instead, you can use Syncfusion DocIO find and replace functionality to replace with table. 

Please check below documentation for reference. 


Please let us know if you have any questions. 


Regards, 
Suriya M. 


Loader.
Up arrow icon