Hi ioStreaM,
Thank you for your interest in Syncfusion products.
1. Add a mergefield before TableEnd:TBL keyword Yes, it is possible to insert the Mergefield at the end of Mail merge table. We can't achieve this directly. For this we need enumerate all the section in the document, and then enumerate paragraphs in each section. In the paragraph we need to check the field type then insert the merge field in the desire place. Please refer the below code snippet to do so:
WordDocument document = new WordDocument(@"..\..\SalesInvoiceDemo.doc");
foreach (Entity ent in document.ChildEntities)
{
if (ent is WSection)
{
WSection section = ent as WSection;
foreach (WParagraph paragraph in section.Body.Paragraphs)
{
int k = 0;
foreach (ParagraphItem item in paragraph.Items)
{
k++;
//check whether item is mergefield
if (item is WField && (item as WField).FieldType == FieldType.FieldMergeField)
{
WMergeField field = item as WMergeField;
//Check the table Name and its Prefix
if (field.Prefix == "TableEnd" && field.FieldName == "Orders")
{
i = 1;
}
}
}
if (i == 1)
{
//Add new mergefield before the table end
ParagraphItem items = document.CreateParagraphItem(ParagraphItemType.MergeField);
WMergeField field = items as WMergeField;
field.FieldName = "NewField";
field.FieldType = FieldType.FieldMergeField;
field.TextFormat = TextFormat.Lowercase;
paragraph.Items.Insert(k-1,items as Entity);
i = 0;
}
}
}
}
Please refer the below sample which illustrate the above specified feature:
http://websamples.syncfusion.com/samples/DocIO.Windows/F74185/main.htm 2. Does it possible to find mailmerge fields on table ?
We have implemented two new methods to get the mail merge table names and to get the specified table fields names. Please refer the below code snippet:
//This will return the Tables in the document
string[] str=document.MailMerge.GetMergeGroupNames();
//This will return the specified group field names
string[] str1=document.MailMerge.GetMergeFieldNames(NameofTable);
These feature only implemented in our latest version Essential Studio Volume 2. We recommend you to upgrade our latest version.
Download Link :
http://www.syncfusion.com/downloads/latestversion/default.aspx Unlock key:If your Essential Studio license is current, you will be able to obtain the key to install this version from your account in DirectTrac. Otherwise, please contact your Syncfusion Sales Representative or e-mail salessupport@syncfusion.com.
Note: Image link that you have sent is not working.
Please try it and let us know if this helps you.
Best Regards,
Bhuvana