BoldSignA modern eSignature application with affordable pricing. Sign up today for unlimited document usage!
Hi
Silvester,
Thank you for your interest in Syncfusion products.
To
remove an existing table from word document, you can simply call below code
snippet.
Code
snippet:
//Get Table object
IWTable table = document.Section[0].Tables[0];
//Remove table if DataTable is empty
if (mDataTable.Rows.Count == 0)
//Remove Table object from the child entity collection of first section’s textbody
document.Section[0].Body.ChildEntities.Remove(table);
//Alternatively you can directly remove the table from child entity collection by providing index (location) in owner collection
document.Section[0].Body.ChildEntities.RemoveAt(0);
We have
prepared a simple sample to illustrate this usage in below link.
Sample Link:
GenerateWord.zip
If you
are using mail merge with Groups in your application, there is an alternate
solution by simply setting RemoveEmptyGroup property of MailMerge class to true
and place the table in the input template within Begin and End Group fields,
DocIO will handle the logic of removing empty groups (elements between Begin
and End Group) when the data table is empty.
Code
snippet:
//Removes Empty Group during Mailmerge
document.MailMerge.RemoveEmptyGroup = true;
We have
prepared a simple sample to illustrate this usage in below link.
Sample Link:
GenerateWord_MailMerge.zip
kindly try running the above samples and let us know
if this helps you.
Regards,
Ananda Kumar V
Hi
Silvester,
Thank
you for your update.
We
have prepared the sample to illustrate your requirement to remove the document
contents which is preserved in between the Merge field of BeginGroup and
EndGroup when the DataTable doesn’t have any records. Please do find the sample
from the attachment, try running the sample and let us know if this helps you.
Please
let us know if you have any other questions.
Regards,
Sathish
Hi Badri,
Thank you for your interest in
Syncfusion products.
Please find the attached sample
which demonstrates how to remove the items preserved between
the Merge field of BeginGroup and EndGroup when the DataTable doesn’t have any
records.
Please let us know if you have any other questions.
Regards,
Sathish