Free Support Forum - aspose.com

Delete the table and move the content below up

Hi,

I want to perform a delete table and move the line below up. How can I work on it in Aspose?

Regards,
Ken Wan

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thanks for your inquiry. It is very easy; you should just find this table and call Remove method. Please note, each node has Remove method.

http://www.aspose.com/documentation/.net-components/aspose.words-for-.net-and-java/aspose.words.node.remove.html

Best regards,

Hi,

We have tried to use a bookmark to locate a table and use .Remove to remove it. But seems it doesn’t work. Any other solution?

we are using:

if (secDoc != null)
builder = new DocumentBuilder(secDoc);
else
builder = new DocumentBuilder(doc);
builder.MoveToBookmark(xmlNode.InnerXml);


Node table = builder.CurrentParagraph.GetAncestor(NodeType.Table);
if (table != null)
{
table.Remove();
}

Also, we have tried to remove rows, but still failed

code is shown below

builder.MoveToBookmark(tableRow);<o:p></o:p>

Node row = builder.CurrentParagraph.GetAncestor(NodeType.Row);

if (row != null)

{

row.Remove();

}

It only delete the content inside rows, but not the whole row(You can reference on the attached PDF). What's the reason?


Regards,
Ken Wan

Hi

<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for additional information. Bookmark should be in a table, which should be removed. For instance, the following code works fine on my side.

Document doc = new Document(@"Test001\PPS_FS_CHT.doc");

// Get bookmark

Bookmark bk = doc.Range.Bookmarks["RIDERPLANS_BOOKMARK"];

if (bk != null)

{

// Get table, where bookmark is located.

Node table = bk.BookmarkStart.GetAncestor(NodeType.Table);

if (table != null)

table.Remove();

}

doc.Save(@"Test001\out.doc");

Best regards,