I'm using the latest build from trunk and Office 2010.
Post by Bart W JenkinsYegor,
Thank you for the code, but this did NOT work for me. Can you tell me
what version of POI you are using? I have 3.8. With this code I get a 3 x
3 table with the column widths set as if they were nearly 0! No matter what
I set for the col sizes, the col sizes are not working.
Bart
XWPFDocument doc = new XWPFDocument();
//column width in Twentieths of a Point
int[] cols = {2000, 2000, 2000};
XWPFTable table = doc.createTable(3, 3);
for(int i = 0; i < table.getNumberOfRows(); i++){
XWPFTableRow row = table.getRow(i);
int numCells = row.getTableCells().size();
for(int j = 0; j < numCells; j++){
XWPFTableCell cell = row.getCell(j);
cell.getCTTc().addNewTcPr().addNewTcW().setW(BigInteger.valueOf(cols[j]));
}
}