I have had a look at the sample code org.docx4j.samples.CreateWordprocessingMLDocument in 2.7.1 provided in this link
http://grepcode.com/file/repo1.maven.org/maven2/org.docx4j/docx4j/2.7.1/org/docx4j/samples/CreateWordprocessingMLDocument.java?av=f
This is what I have done
- Code: Select all
// Add a table
int writableWidthTwips = wordMLPackage.getDocumentModel().getSections().get(0).getPageDimensions().getWritableWidthTwips();
int cols = 5;
int cellWidthTwips = new Double(Math.floor((writableWidthTwips/cols))).intValue();
Tbl tbl = TblFactory.createTable(1, 5, cellWidthTwips);
wordMLPackage.getMainDocumentPart().addObject(tbl);
I have managed to create a table ...