poi中,如何向Word文档里添加表格?

来源:百度知道 编辑:UC知道 时间:2024/05/21 21:10:55
如题

//创建一个表格
XWPFTable table = doc.createTable(4,2);
table.setCellMargins(50, 0, 50,3000);//top, left, bottom, right
// table.setInsideHBorder(XWPFBorderType.NONE, 0, 0, "");//去除单元格间的横线
table.getRow(0).getCell(0).setText("字段一:");
table.getRow(0).getCell(1).setText("字段二:");
table.getRow(1).getCell(0).setText("字段三:");
table.getRow(1).getCell(1).setText("字段四:");