[DocIO] - How access index in TableStart or BeginGroup ?

Hi

I need access a specific data in array in word template

My template use «TableStart:TableName» 

how access index in tablestart array?

5 Replies

MJ Mohanaselvam Jothi Syncfusion Team May 9, 2018 09:19 AM UTC

Hi Marcelo,

Thank you for contacting Syncfusion support.

We suspect that your requirement is to get the index of field name in the Merge Field group from the template Word document. We suggest you to use GetMergeFieldNames API to retrieve the merge field names from a specific merge field group in the Word document. This returns the field names as per the order defined in the template Word document and you can get the index of particular field name using this .

Please refer the below code example to retrieve the merge field names for specific merge field group in the document:
 
//Gets the fields from the specified groups.  
string[] fieldNames = document.MailMerge.GetMergeFieldNames(groupName); 
//Get the index of Field name. 
int index = Array.IndexOf(fieldNames, "Field"); 


Please refer the below UG documentation link to know about retrieving the merge field names in document using DocIO:
https://help.syncfusion.com/file-formats/docio/working-with-mailmerge#retrieving-the-merge-field-names

If we misunderstood any of your requirement means, then could you please elaborate us about your exact requirement along with the expected results. This will be helpful to check the feasibilities to achieve it and update you the more details.


Please let us know if you have any other questions.

Regards,
Mohanaselvam J
 



MA Marcelo May 9, 2018 11:43 AM UTC

I have a list, and if it comes many records in the document.docx template I want to split it into two tables.

So I need to have the index in the word document and not in the C# api

Is there any way to access the index in the word document (docx)?


MJ Mohanaselvam Jothi Syncfusion Team May 11, 2018 02:23 AM UTC

Hi Marcelo,

Thank you for your update.

From the given details, we have prepared the sample application to split merge field group in the Word document using the index of particular merge field. Please find the sample from the below link and let us know if this helps you:
http://www.syncfusion.com/downloads/support/forum/137452/ze/GenerateWord-1880553196.zip
Note: Please find the template Word document in “Data” folder of above sample application.

In this sample we have done the following things:
   1. Opens an template Word document using DocIO.
   2. Gets the fields in the document.
   3. Splits the existing merge field group into two groups.
   4. Saves the Word document.

If the above sample does not satisfies your requirement means, kindly provide us the input Word document and expected output Word document from your end. This will be helpful to analyze the feasibility to achieve your requirement using DocIO and provide you the appropriate solution.
Note: If you have any confidential data in your Word document, please replace with some dummy data and provide us the same.


Please let us know if you have any other questions.

Regards,
Mohanaselvam J
 



MA Marcelo June 4, 2018 08:23 PM UTC

Hi, maybe I expressed myself wrong.

I have a list with 20 records or dynamically
And I want to generate a table with 2 columns and 10 rows for example.

Now I use html template, using MyList[0].Property, MyList[1].Property ...

I think my question has now been clear.

Thank you

Eq:

Item 1Item 2
Item 3Item 4
Item 5Item 6
Item 7
Item 8
Item 9 
Item 10
Item 11
Item 12
Item 13
Item 14
Item 15
Item 16
Item 17
Item 18
Item 19
Item 20


MJ Mohanaselvam Jothi Syncfusion Team June 5, 2018 10:38 AM UTC

Hi Marcelo,

Thank you for your update.

To achieve your requirement, we have prepared a sample application to perform mail merge using the dynamic data in the Word document.

Please refer the sample from the below link:
http://www.syncfusion.com/downloads/support/forum/137452/ze/GenerateWord-1922441919.zip  
Note: Please find the template Word document in the “Data” folder of above sample to meet your requirement.

We have done the following things in the sample:
  1. Loads a template Word document.
  2. Creates data table based on given record count dynamically.
  3. Executes mail merge functionality.
  4. Saves the Word document.

To merge different data for same merge fields as per the DataTable (dynamic data), we suggest you to prepare template Word document as per below:
  1. Creates a table with two columns.
  2. Add merge fields in two cells of first row in the table.

To merge another data value (another record) to the same merge fields of another cell, we suggest to add “Next” field at the end of merge field in first cell. Thus, after executing mail merge for first cell, the data values of next row (next record) are merged into fields in another cell (second cell in first row).

Please let us know if you have any other questions.

Regards,
Mohanaselvam J
 


Loader.
Up arrow icon