Page 1 of 1

Copying the existing table and adding it in the document

PostPosted: Wed Mar 06, 2019 4:36 pm
by jitheshkulal96
Hi,

I have a use case to copy the existing table in a document and add it to the same document right after the existing table.
Can any one help me with this?

Thanks :)

Re: Copying the existing table and adding it in the document

PostPosted: Tue Mar 12, 2019 5:01 pm
by jason
Three steps:

1. get a reference to your existing table object
2. clone it (XmlUtils.deepCopy)
3. add the clone to content list

This will work for simple text content; it assumes your table doesn't contain rels to other parts, or eg bookmark or comment tags. Things like that can require additional handling.