Hi.
How can i insert or replace Text after deep clone. I have done deep cloning this way.
table.appendChild(table.getLastRow().deepClone(true);
Sunil
Hi.
How can i insert or replace Text after deep clone. I have done deep cloning this way.
table.appendChild(table.getLastRow().deepClone(true);
Sunil
Hi
Thanks for your request. You can use the following code:
// Open Document and create DocumentBuilder
Document doc = new Document("C:\\Temp\\in.doc");
DocumentBuilder builder = new DocumentBuilder(doc);
// Get table
Table table = doc.getFirstSection().getBody().getTables().get(0);
// clone last row
table.appendChild(table.getLastRow().deepClone(true));
// Remove ald values from the last row
for (Cell cell : table.getLastRow().getCells())
{
// remove paragraphs if there is more then one paragraph
while (cell.getParagraphs().getCount() > 1)
{
cell.getLastParagraph().remove();
}
// remove all children from first paragraph of cell
cell.getFirstParagraph().getChildNodes().clear();
// Insert new value
builder.moveTo(cell.getFirstParagraph());
builder.write("This is new value");
}
// Save output document
doc.save("C:\\Temp\\out.doc");
Hope this helps.
Best regards.