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

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.
https://reference.aspose.com/words/net/aspose.words/node/remove/
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");
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

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,