Hi,
I’m trying to clone a table and insert several copies of the clone into multiple locations in the same document. For example:
Node SrcNode = Tables[5].Clone(true);
Node DestNode = Tables[0];
Table NewTable = (Table) DestNode.ParentNode.InsertAfter(SrcNode, DestNode);
This does work, but I have a couple of questions:
- I want to insert a line-break (basically an empty line) between the destination table and the inserted table (now, after inserting, the two tables have no space between them). How can I do that ? I’ve tried this:
Builder.MoveTo(DestNode.GetAncestor(NodeType.Body));
Builder.Writeln();
but I get an exception “The node must be a paragraph or a direct child of a paragraph”. If I use NodeType.Paragraph instead, the nodetype is null and I get a null exception.
- When trying to insert several copies of the same table, only the first one succeeds. For example, calling the InsertAfter method several times, only a single copy gets inserted. The Help file states that “If the newChild is already in the tree, it is first removed.” which might explain why. But then how can you accomplish this ? What constitutes a “new” child ?
Best regards and thanks,
Michael