I am trying to draw a table in word document using Apache POI XWPF. But the table is drawing with double height rows like this
Here is my source
XWPFTable table = document.createTable(5, 1);
for (Test t : tests) {
XWPFTableRow row = table.getRow(k - 1);
XWPFTableCell cell = row.getCell(0);
XWPFParagraph ansParagraph = new XWPFParagraph(cell.getCTTc().insertNewP(0), cell);
XWPFRun ansRun = ansParagraph.createRun();
ansRun.setText(k + ") ");
cell.addParagraph(ansParagraph);
k++;
}
how can I reduced the height of row.
When you create a table in Apache POI XWPF it already has a blank paragraph in every cell. You are getting double height rows because you are also adding a paragraph in it.
So you replace the line
with
And remove the line
Then it will work OK.