Joining tables inserted from external documents

Hi

We have an application that produces multiple tables each with a single row and saves each of them as a single document. We then do a series of InsertDocument actions to insert them one after the other into a designated place in a master document.

The issue is that each inserted document and its table ends up as separate tables with a paragraph mark after each inserted table. What we want to do is to remove these paragraph marks which will then automatically join the table to the one above and when finished, we can use an =SUM(ABOVE) function to total the columns.

In the past we did this with a WordMacro that searched for a location and then pressed delete twice and the tables were joined.

How can I do this in Aspose?

I have attached the source document as well as the current result of the Aspose MailMerge.Execute and the desired result.

For a great deal of reasons, we cant change this code to use the MailMerge.ExecuteWithRegions

Thanks

Hi Brian,

Thanks for your inquiry. Please remove empty paragraphs between tables to get the desired output. You can use following code snippet before saving the document to get the desired output. Hope this helps you.

If you still face problem, please create a standalone console application (source code without compilation errors) that helps us to reproduce your problem on our end and attach it here for testing. We will investigate the issue on our side and provide you more information.

foreach (Table table in doc.GetChildNodes(NodeType.Table, true))
{
    if (table.NextSibling != null && table.NextSibling.NodeType == NodeType.Paragraph
    && table.NextSibling.NextSibling != null && table.NextSibling.NextSibling.NodeType == NodeType.Table)
    {
        if (((Paragraph)table.NextSibling).Runs.Count == 0)
            table.NextSibling.Remove();
    }
}
doc.UpdatePageLayout();
doc.UpdateFields();
doc.Save(MyDir + "Out.docx");