Skip to content

Commit

Permalink
Update RowUtil.java (Row addition update)
Browse files Browse the repository at this point in the history
  • Loading branch information
DivyaJakkampudi authored Oct 12, 2023
1 parent 5a1ab73 commit 88f91e1
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,15 +53,19 @@ public boolean RowAddition(
if(dataList.size() != oldRow.getTableCells().size()){
throw new InputMismatchException("Given data items size is incompatible with specified table row");
}
for (XWPFTableCell cell : newRow.getTableCells()) {
cell.removeParagraph(0);
cell.setText("");
for (XWPFTableCell cell : newRow.getTableCells()){
cell.removeParagraph(0);
cell.setText("");
for(XWPFParagraph paragraph : cell.getParagraphs()){
for(XWPFRun run : paragraph.getRuns()){
run.setText(" ",0);// Remove the existing paragraph
}
}
}

for (int index = 0; index < newRow.getTableCells().size(); index++) {
XWPFParagraph paragraph = newRow.getCell(index).addParagraph();
XWPFRun run = paragraph.createRun();
run.setText(dataList.get(index));
XWPFTableCell cell = newRow.getCell(index);
cell.setText(dataList.get(index));
}
table.addRow(newRow, position);
FileOutputStream fos = new FileOutputStream(documentPath);
Expand Down

0 comments on commit 88f91e1

Please sign in to comment.