Hello,
I have a Word document that contains a table. My goal is to copy the the table (with Table.Clone) and to insert another copy of the table right after the current table. I’m trying to use Table.InsertAfter() but I’m not getting it quite right.
Would you be so kind as to suggest how best to accomplish this?
Thank you!
My current code is:
// Find the field reference
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToMergeField("TableGroup");
int numberOfCopies = 2; // An arbitrary value
if (builder.CurrentParagraph.IsInCell)
{
Aspose.Words.Tables.Cell cell = (Aspose.Words.Tables.Cell)builder.CurrentParagraph.ParentNode;
Aspose.Words.Tables.Table table = cell.ParentRow.ParentTable;
for (int k = 0; k < numberOfCopies; k++)
{
Aspose.Words.Tables.Table newTable = (Aspose.Words.Tables.Table)table.Clone(true);
table.InsertAfter(newTable, builder.CurrentParagraph);
}
}