XWPFDocument doc = new XWPFDocument(); //创建对象
XWPFParagraph p1 = doc.createParagraph();
p1.setAlignment(ParagraphAlignment.CENTER);
p1.setVerticalAlignment(TextAlignment.TOP);
//创建table
XWPFTable table = doc.createTable(6, 4);
//表格属性
table.setCellMargins(500, 200, 300, 400);
//行数
List<XWPFTableRow> tRows = table.getRows();
//第1行
XWPFTableRow tRow0 = tRows.get(0);
//列数
List<XWPFTableCell> tCell0 = tRow0.getTableCells();
tCell0.get(0).setText("维修单号"); //table 表格赋值
ServletOutputStream out = null;
String wordName = "维修订单.docx";
response.setContentType("application/x-msdownloadoctet-stream;charset=utf-8");
response.setHeader("Content-Disposition", "attachment; filename="+ URLEncoder.encode(wordName, "UTF-8"));
out=response.getOutputStream();
doc.write(out);
out.flush();
out.close();
//生产doc文档 保存