1.新增表格,设置宽度和居中
XWPFTable table = document.createTable();
CTTblPr tblPr = table.getCTTbl().addNewTblPr();
tblPr.addNewJc().setVal(STJc.CENTER);
CTTblWidth tableWidth = tblPr.addNewTblW();
tableWidth.setType(STTblWidth.DXA);
tableWidth.setW(BigInteger.valueOf(11072));
2.新增一行,调整宽度
XWPFTableRow row = table.getRow(0);
XWPFTableCell tableCell = row.addNewTableCell();
CTTcPr ctTcPr = tableCell.getCTTc().isSetTcPr() ? tableCell.getCTTc().getTcPr() : tableCell.getCTTc().addNewTcPr();
CTTblWidth ctTblWidth = ctTcPr.addNewTcW();
ctTblWidth.setW(BigInteger.valueOf(100));
ctTblWidth.setType(STTblWidth.DXA);
3.单个表格设置文字大小
XWPFTableCell tableCell = row.getCell(0);
XWPFRun run = tableCell.addParagraph().createRun();
run.setText(String.valueOf(4396));
run.