We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy.
Unfortunately, activation email could not send to your email. Please try again.

MailMerge - Table

Thread ID:

Created:

Updated:

Platform:

Replies:

74185 Jun 3,2008 04:31 AM Jun 9,2008 01:56 AM Windows Forms 6
loading
Tags: DocIO
Administrator [Syncfusion]
Asked On June 3, 2008 04:31 AM

Hello,

Does it possible to find mailmerge fields on table ?
I wanna want adding mailmerge field inside a table.

Example: add a mergefield before TableEnd:TBL keyword

[IMG]http://img136.imageshack.us/img136/1874/sanstitrewk4.jpg[/IMG]

The GetMergeFieldNames() Of MailMerge Class Can find it.
But I want to know the section whose contains this fields...





Bhuvaneswari P [Syncfusion]
Replied On June 3, 2008 06:18 AM

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



Administrator [Syncfusion]
Replied On June 3, 2008 08:24 AM

Great, i will try


Administrator [Syncfusion]
Replied On June 3, 2008 08:57 AM

Unfortunately my WMergeField class version does not have Prefix Property
Can have it by other way ?

http://img529.imageshack.us/img529/6167/sanstitrepk6.jpg


Bhuvaneswari P [Syncfusion]
Replied On June 4, 2008 02:52 AM

Hi ioStreaM,

Thanks for the update.

Yes, it is possible to check the filed TableEnd using the Text property of Field. Please refer the below code snippet to test it.


//check whether item is mergefield or not
if (item is WField && (item as WField).FieldType == FieldType.FieldMergeField)
{
WMergeField field = item as WMergeField;
string s = field.Text;
//Check the table Name and its Prefix
if (field.FieldName == "Orders" && s.Contains("TableEnd"))
{
i = 1;
break;
}




Here is the modified sample for your reference:

http://www.syncfusion.com/development/uploads/AddMergeField_f8e6acfd.zip


Note: We can't insert the field exactly before the TableEnd field. Because ParagraphitemType as Mergefield features are implemented in only in our latest. So we can't create a Paragraph item for mergefield and insert into the particular paragraph item. So In this sample I have inserted in the paragraph.

Please let me know if you have any concern.

Best Regards,
Bhuvana



Administrator [Syncfusion]
Replied On June 4, 2008 03:35 AM

It works fine.
But I must say my customer to upgrade his syncfusion version


Bhuvaneswari P [Syncfusion]
Replied On June 9, 2008 01:56 AM

Hi,

Glad to know that the workaround resolve the issue.

Please let me know if you have any other questions.

Best Regards,
Bhuvana


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;