XWPFDocument document = new XWPFDocument();
XWPFTable infoTable = document.createTable();
infoTable.setInsideHBorder(XWPFTable.XWPFBorderType.THICK, 2, 2, "000000");
infoTable.setInsideVBorder(XWPFTable.XWPFBorderType.THICK, 2, 2, "000000");
infoTable.setTableAlignment(TableRowAlign.CENTER);
CTTblWidth infoTableWidth = infoTable.getCTTbl().addNewTblPr().addNewTblW();
infoTableWidth.setType(STTblWidth.DXA);
infoTableWidth.setW(WordSizeEnum.EIGHT.getCode());
CTTblPr ctTblPr = infoTable.getCTTbl().addNewTblPr();
CTTblLayoutType tblLayout = ctTblPr.addNewTblLayout();
tblLayout.setType(STTblLayoutType.FIXED);
XWPFTableRow infoTableRowOne = infoTable.getRow(0);
infoTableRowOne.setHeight(600);
getCell(infoTableRowOne.getCell(0), WordSizeEnum.EIGHT.getCode(), WordFontEnum.CH.getCode(), 15, "基本信息", true);
大概样子如下(参考):
