Row split

Hi Team,

How to split the row into two rows. I’ve shared the input and expected output documents, which are attached here. Please assist me.

Input: Input.docx (29.4 KB)
Excepted output: ExceptedOutput.docx (29.3 KB)

Regards,
Mahi

@Mahi39

Can you please provide more details on how you would like to split the row? Are you looking to split a table row in a Word document, and if so, what criteria should be used for the split?

@Mahi39 You can use the following code to get the expected output:

Document document = new Document("C:\\Temp\\in.docx");

Table t = document.getFirstSection().getBody().getTables().get(0);
// Get row.
Row r = t.getRows().get(1);
// Clone the row and insert it before the row.
Row clone = (Row)r.deepClone(true);
clone.getChildNodes(NodeType.PARAGRAPH, true).clear();
r.getParentTable().insertBefore(clone, r);
// Move the first paragraph from the row to the cloned row.
clone.getFirstCell().appendChild(r.getFirstCell().getFirstParagraph());

document.save("C:\\Temp\\out.docx");