I'am a beginner in Apache POI and want to extend an existing table in the word template file with some rows. If I use that code below, the table will be extended with row bit the new row's cells created normal style.
My goal is the cells have the same table cells style etc (font, with, height...)
XWPFDocument doc = new XWPFDocument(openFile(fileName));
XWPFTable tbl = doc.getTableArray(tableIndex);
XWPFTableRow lastRow = tbl.getRows().get(tbl.getNumberOfRows() - 1);
cellCounter = lastRow.getTableICells().size();
XWPFTableRow newRow = tbl.createRow();
for (int i = 0; i < data.size() && cellCounter <= data.size(); i++) {
String text = data.get(i);
XWPFTableCell cell = newRow.getCell(i);
if (cell != null) {
cell.setText(text);
}
}
Thanks for your answer. R.