先来张图片

public static void main(String[] args) throws Exception {Test t2 = new Test();t2.createTable();}/*** @Description: 添加方块♢*/public void setCellContentCommonFunction(XWPFTableCell cell, String content)throws Exception {XWPFParagraph p = cell.addParagraph();setParagraphSpacingInfo(p, true, "0", "0", "0", "0", true, "300",STLineSpacingRule.AUTO);setParagraphAlignInfo(p, ParagraphAlignment.BOTH, TextAlignment.CENTER);XWPFRun pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunSymInfo(p, pRun, "宋体", "Times New Roman", "21", true,false, false, 0, 6, 0);pRun = getOrAddParagraphFirstRun(p, true, false);setParagraphRunFontInfo(p, pRun, content, "宋体", "Times New Roman","21", true, false, false, false, null, null, 0, 6, 0);}/*** @Description: 保存文档*/public void saveDocument(XWPFDocument document, String savePath)throws Exception {FileOutputStream fos = new FileOutputStream(savePath);document.write(fos);fos.close();}/*** @Description: 得到单元格第一个Paragraph*/public XWPFParagraph getCellFirstParagraph(XWPFTableCell cell) {XWPFParagraph p;if (cell.getParagraphs() != null && cell.getParagraphs().size() > 0) {p = cell.getParagraphs().get(0);} else {p = cell.addParagraph();}return p;}/*** @Description: 得到段落CTPPr*/public CTPPr getParagraphCTPPr(XWPFParagraph p) {CTPPr pPPr = null;if (p.getCTP() != null) {if (p.getCTP().getPPr() != null) {pPPr = p.getCTP().getPPr();} else {pPPr = p.getCTP().addNewPPr();}}return pPPr;}/*** @Description: 设置段落间距信息,一行=100 一磅=20*/public void setParagraphSpacingInfo(XWPFParagraph p, boolean isSpace,String before, String after, String beforeLines, String afterLines,boolean isLine, String line, STLineSpacingRule.Enum lineValue) {CTPPr pPPr = getParagraphCTPPr(p);CTSpacing pSpacing = pPPr.getSpacing() != null ? pPPr.getSpacing(): pPPr.addNewSpacing();if (isSpace) {// 段前磅数if (before != null) {pSpacing.setBefore(new BigInteger(before));}// 段后磅数if (after != null) {pSpacing.setAfter(new BigInteger(after));}// 段前行数if (beforeLines != null) {pSpacing.setBeforeLines(new BigInteger(beforeLines));}// 段后行数if (afterLines != null) {pSpacing.setAfterLines(new BigInteger(afterLines));}}// 间距if (isLine) {if (line != null) {pSpacing.setLine(new BigInteger(line));}if (lineValue != null) {pSpacing.setLineRule(lineValue);}}}/*** @Description: 设置段落文本样式(高亮与底纹显示效果不同)设置字符间距信息(CTSignedTwipsMeasure)* @param verticalAlign*            : SUPERSCRIPT上标 SUBSCRIPT下标* @param position*            :字符间距位置:>0提升 <0降低=磅值*2 如3磅=6* @param spacingValue*            :字符间距间距 >0加宽 <0紧缩 =磅值*20 如2磅=40* @param indent*            :字符间距缩进 <100 缩*/public void setParagraphRunFontInfo(XWPFParagraph p, XWPFRun pRun,String content, String cnFontFamily, String enFontFamily,String fontSize, boolean isBlod, boolean isItalic,boolean isStrike, boolean isShd, String shdColor,STShd.Enum shdStyle, int position, int spacingValue, int indent) {CTRPr pRpr = getRunCTRPr(p, pRun);if (StringUtils.isNotBlank(content)) {// pRun.setText(content);if (content.contains("\n")) {// System.properties("line.separator")String[] lines = content.split("\n");pRun.setText(lines[0], 0); // set first line into XWPFRunfor (int i = 1; i < lines.length; i++) {// add break and insert new textpRun.addBreak();pRun.setText(lines[i]);}} else {pRun.setText(content, 0);}}// 设置字体CTFonts fonts = pRpr.isSetRFonts() ? pRpr.getRFonts() : pRpr.addNewRFonts();if (StringUtils.isNotBlank(enFontFamily)) {fonts.setAscii(enFontFamily);fonts.setHAnsi(enFontFamily);}if (StringUtils.isNotBlank(cnFontFamily)) {fonts.setEastAsia(cnFontFamily);fonts.setHint(STHint.EAST_ASIA);}// 设置字体大小CTHpsMeasure sz = pRpr.isSetSz() ? pRpr.getSz() : pRpr.addNewSz();sz.setVal(new BigInteger(fontSize));CTHpsMeasure szCs = pRpr.isSetSzCs() ? pRpr.getSzCs() : pRpr.addNewSzCs();szCs.setVal(new BigInteger(fontSize));// 设置字体样式// 加粗if (isBlod) {pRun.setBold(isBlod);}// 倾斜if (isItalic) {pRun.setItalic(isItalic);}// 删除线if (isStrike) {pRun.setStrike(isStrike);}if (isShd) {// 设置底纹CTShd shd = pRpr.isSetShd() ? pRpr.getShd() : pRpr.addNewShd();if (shdStyle != null) {shd.setVal(shdStyle);}if (shdColor != null) {shd.setColor(shdColor);shd.setFill(shdColor);}}// 设置文本位置if (position != 0) {pRun.setTextPosition(position);}if (spacingValue > 0) {// 设置字符间距信息CTSignedTwipsMeasure ctSTwipsMeasure = pRpr.isSetSpacing() ? pRpr.getSpacing() : pRpr.addNewSpacing();ctSTwipsMeasure.setVal(new BigInteger(String.valueOf(spacingValue)));}if (indent > 0) {CTTextScale paramCTTextScale = pRpr.isSetW() ? pRpr.getW() : pRpr.addNewW();paramCTTextScale.setVal(indent);}}/*** @Description: 得到XWPFRun的CTRPr*/public CTRPr getRunCTRPr(XWPFParagraph p, XWPFRun pRun) {CTRPr pRpr = null;if (pRun.getCTR() != null) {pRpr = pRun.getCTR().getRPr();if (pRpr == null) {pRpr = pRun.getCTR().addNewRPr();}} else {pRpr = p.getCTP().addNewR().addNewRPr();}return pRpr;}/*** @Description: 设置段落对齐*/public void setParagraphAlignInfo(XWPFParagraph p,ParagraphAlignment pAlign, TextAlignment valign) {if (pAlign != null) {p.setAlignment(pAlign);}if (valign != null) {p.setVerticalAlignment(valign);}}public XWPFRun getOrAddParagraphFirstRun(XWPFParagraph p, boolean isInsert,boolean isNewLine) {XWPFRun pRun = null;if (isInsert) {pRun = p.createRun();} else {if (p.getRuns() != null && p.getRuns().size() > 0) {pRun = p.getRuns().get(0);} else {pRun = p.createRun();}}if (isNewLine) {pRun.addBreak();}return pRun;}/*** @Description: 设置Table的边框*/public void setTableBorders(XWPFTable table, STBorder.Enum borderType,String size, String color, String space) {CTTblPr tblPr = getTableCTTblPr(table);CTTblBorders borders = tblPr.isSetTblBorders() ? tblPr.getTblBorders(): tblPr.addNewTblBorders();CTBorder hBorder = borders.isSetInsideH() ? borders.getInsideH(): borders.addNewInsideH();hBorder.setVal(borderType);hBorder.setSz(new BigInteger(size));hBorder.setColor(color);hBorder.setSpace(new BigInteger(space));CTBorder vBorder = borders.isSetInsideV() ? borders.getInsideV(): borders.addNewInsideV();vBorder.setVal(borderType);vBorder.setSz(new BigInteger(size));vBorder.setColor(color);vBorder.setSpace(new BigInteger(space));CTBorder lBorder = borders.isSetLeft() ? borders.getLeft() : borders.addNewLeft();lBorder.setVal(borderType);lBorder.setSz(new BigInteger(size));lBorder.setColor(color);lBorder.setSpace(new BigInteger(space));CTBorder rBorder = borders.isSetRight() ? borders.getRight() : borders.addNewRight();rBorder.setVal(borderType);rBorder.setSz(new BigInteger(size));rBorder.setColor(color);rBorder.setSpace(new BigInteger(space));CTBorder tBorder = borders.isSetTop() ? borders.getTop() : borders.addNewTop();tBorder.setVal(borderType);tBorder.setSz(new BigInteger(size));tBorder.setColor(color);tBorder.setSpace(new BigInteger(space));CTBorder bBorder = borders.isSetBottom() ? borders.getBottom(): borders.addNewBottom();bBorder.setVal(borderType);bBorder.setSz(new BigInteger(size));bBorder.setColor(color);bBorder.setSpace(new BigInteger(space));}/*** @Description: 得到Table的CTTblPr,不存在则新建*/public CTTblPr getTableCTTblPr(XWPFTable table) {CTTbl ttbl = table.getCTTbl();CTTblPr tblPr = ttbl.getTblPr() == null ? ttbl.addNewTblPr() : ttbl.getTblPr();return tblPr;}/*** @Description: 设置列宽和垂直对齐方式*/public void setCellWidthAndVAlign(XWPFTableCell cell, String width,STTblWidth.Enum typeEnum, STVerticalJc.Enum vAlign) {CTTcPr tcPr = getCellCTTcPr(cell);CTTblWidth tcw = tcPr.isSetTcW() ? tcPr.getTcW() : tcPr.addNewTcW();if (width != null) {tcw.setW(new BigInteger(width));}if (typeEnum != null) {tcw.setType(typeEnum);}if (vAlign != null) {CTVerticalJc vJc = tcPr.isSetVAlign() ? tcPr.getVAlign() : tcPr.addNewVAlign();vJc.setVal(vAlign);}}/*** @Description: 跨列合并*/public void mergeCellsHorizontal(XWPFTable table, int row, int fromCell,int toCell) {for (int cellIndex = fromCell; cellIndex <= toCell; cellIndex++) {XWPFTableCell cell = table.getRow(row).getCell(cellIndex);if (cellIndex == fromCell) {// The first merged cell is set with RESTART merge valuegetCellCTTcPr(cell).addNewHMerge().setVal(STMerge.RESTART);} else {// Cells which join (merge) the first one,are set with CONTINUEgetCellCTTcPr(cell).addNewHMerge().setVal(STMerge.CONTINUE);}}}/*** * @Description: 得到Cell的CTTcPr,不存在则新建*/public CTTcPr getCellCTTcPr(XWPFTableCell cell) {CTTc cttc = cell.getCTTc();CTTcPr tcPr = cttc.isSetTcPr() ? cttc.getTcPr() : cttc.addNewTcPr();return tcPr;}/*** @Description: 设置表格列宽*/public void setTableGridCol(XWPFTable table, int[] colWidths) {CTTbl ttbl = table.getCTTbl();CTTblGrid tblGrid = ttbl.getTblGrid() != null ? ttbl.getTblGrid(): ttbl.addNewTblGrid();for (int j = 0, len = colWidths.length; j < len; j++) {CTTblGridCol gridCol = tblGrid.addNewGridCol();gridCol.setW(new BigInteger(String.valueOf(colWidths[j])));}}public void setParagraphRunSymInfo(XWPFParagraph p, XWPFRun pRun,String cnFontFamily, String enFontFamily, String fontSize,boolean isBlod, boolean isItalic, boolean isStrike, int position,int spacingValue, int indent) throws Exception {CTRPr pRpr = getRunCTRPr(p, pRun);// 设置字体CTFonts fonts = pRpr.isSetRFonts() ? pRpr.getRFonts() : pRpr.addNewRFonts();if (StringUtils.isNotBlank(enFontFamily)) {fonts.setAscii(enFontFamily);fonts.setHAnsi(enFontFamily);}if (StringUtils.isNotBlank(cnFontFamily)) {fonts.setEastAsia(cnFontFamily);fonts.setHint(STHint.EAST_ASIA);}// 设置字体大小CTHpsMeasure sz = pRpr.isSetSz() ? pRpr.getSz() : pRpr.addNewSz();sz.setVal(new BigInteger(fontSize));CTHpsMeasure szCs = pRpr.isSetSzCs() ? pRpr.getSzCs() : pRpr.addNewSzCs();szCs.setVal(new BigInteger(fontSize));// 设置字体样式// 加粗if (isBlod) {pRun.setBold(isBlod);}// 倾斜if (isItalic) {pRun.setItalic(isItalic);}// 删除线if (isStrike) {pRun.setStrike(isStrike);}// 设置文本位置if (position != 0) {pRun.setTextPosition(position);}if (spacingValue > 0) {// 设置字符间距信息CTSignedTwipsMeasure ctSTwipsMeasure = pRpr.isSetSpacing() ? pRpr.getSpacing() : pRpr.addNewSpacing();ctSTwipsMeasure.setVal(new BigInteger(String.valueOf(spacingValue)));}if (indent > 0) {CTTextScale paramCTTextScale = pRpr.isSetW() ? pRpr.getW() : pRpr.addNewW();paramCTTextScale.setVal(indent);}List<CTSym> symList = pRun.getCTR().getSymList();CTSym sym = CTSym.Factory.parse("<xml-fragment w:font=\"Wingdings 2\" w:char=\"00A3\" xmlns:w=\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\" xmlns:wne=\"http://schemas.microsoft.com/office/word/2006/wordml\"> </xml-fragment>");symList.add(sym);}/*** @Description: 设置表格总宽度与水平对齐方式*/public void setTableWidthAndHAlign(XWPFTable table, String width,STJc.Enum enumValue) {CTTblPr tblPr = getTableCTTblPr(table);CTTblWidth tblWidth = tblPr.isSetTblW() ? tblPr.getTblW() : tblPr.addNewTblW();if (enumValue != null) {CTJc cTJc = tblPr.addNewJc();cTJc.setVal(enumValue);}tblWidth.setW(new BigInteger(width));tblWidth.setType(STTblWidth.DXA);}/*** @Description: 设置单元格Margin*/public void setTableCellMargin(XWPFTable table, int top, int left,int bottom, int right) {table.setCellMargins(top, left, bottom, right);}/*** @Description: 得到CTTrPr,不存在则新建*/public CTTrPr getRowCTTrPr(XWPFTableRow row) {CTRow ctRow = row.getCtRow();CTTrPr trPr = ctRow.isSetTrPr() ? ctRow.getTrPr() : ctRow.addNewTrPr();return trPr;}/*** @Description: 设置行高*/public void setRowHeight(XWPFTableRow row, String hight,STHeightRule.Enum heigthEnum) {CTTrPr trPr = getRowCTTrPr(row);CTHeight trHeight;if (trPr.getTrHeightList() != null && trPr.getTrHeightList().size() > 0) {trHeight = trPr.getTrHeightList().get(0);} else {trHeight = trPr.addNewTrHeight();}trHeight.setVal(new BigInteger(hight));if (heigthEnum != null) {trHeight.setHRule(heigthEnum);}}/*** @Description: 设置底纹*/public void setCellShdStyle(XWPFTableCell cell, boolean isShd,String shdColor, STShd.Enum shdStyle) {CTTcPr tcPr = getCellCTTcPr(cell);if (isShd) {// 设置底纹CTShd shd = tcPr.isSetShd() ? tcPr.getShd() : tcPr.addNewShd();if (shdStyle != null) {shd.setVal(shdStyle);}if (shdColor != null) {shd.setColor(shdColor);shd.setFill(shdColor);}}}public void createTable() throws Exception {XWPFDocument xdoc = new XWPFDocument();XWPFParagraph p = xdoc.createParagraph();// 固定值25磅setParagraphSpacingInfo(p, true, "0", "80", null, null, true, "500", STLineSpacingRule.EXACT);// 居中setParagraphAlignInfo(p, ParagraphAlignment.CENTER,TextAlignment.CENTER);XWPFRun pRun = getOrAddParagraphFirstRun(p, false, false);/**设置标题头*/setParagraphRunFontInfo(p, pRun, "××××(××)事件报告表", "宋体", "Times New Roman", "36", true, false, false, false, null, null, 0, 0, 90);p = xdoc.createParagraph();// 固定值25磅setParagraphSpacingInfo(p, true, "0", "80", null, null, true, "500", STLineSpacingRule.EXACT);// 居中setParagraphAlignInfo(p, ParagraphAlignment.CENTER, TextAlignment.CENTER);pRun = getOrAddParagraphFirstRun(p, false, false);/**作者*/setParagraphRunFontInfo(p, pRun, "小沈哥", "宋体", "Times New Roman", "36", true, false, false, false, null, null, 0, 0, 90);p = xdoc.createParagraph();// 单倍行距setParagraphSpacingInfo(p, true, "0", "0", "0", "0", true, "240", STLineSpacingRule.AUTO);setParagraphAlignInfo(p, ParagraphAlignment.LEFT, TextAlignment.CENTER);pRun = getOrAddParagraphFirstRun(p, false, false);/**文档描叙*/setParagraphRunFontInfo(p, pRun, "﹡报告日期:年月日﹡ 事件发生日期:年月日", "宋体", "Times New Roman", "24", true, false, false, false, null, null, 0, 6, 0);// 创建表格21行3列XWPFTable table = xdoc.createTable(21, 4);setTableBorders(table, STBorder.SINGLE, "4", "auto", "0");setTableWidthAndHAlign(table, "9024", STJc.CENTER);setTableCellMargin(table, 0, 108, 0, 108);int[] colWidths = new int[] { 2169, 2638, 525, 3692 };setTableGridCol(table, colWidths);XWPFTableRow row = table.getRow(0);setRowHeight(row, "460", STHeightRule.AT_LEAST);XWPFTableCell cell = row.getCell(0);setCellShdStyle(cell, true, "FFFFFF", null);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "A.负责人或部门资料 ﹡", "宋体", "Times New Roman", "24", true, false, false, false, null, null, 0, 6, 0);mergeCellsHorizontal(table, 0, 0, 3);row = table.getRow(1);setRowHeight(row, "567", STHeightRule.AT_LEAST);cell = row.getCell(0);setCellWidthAndVAlign(cell, "2169", STTblWidth.DXA, STVerticalJc.TOP);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "1.负责人:", "宋体", "Times New Roman", "21", false, false, false, false, null, null, 0, 6, 0);cell = row.getCell(1);setCellWidthAndVAlign(cell, "3163", STTblWidth.DXA, STVerticalJc.TOP);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "2.负责部门:", "宋体", "Times New Roman", "21", false, false, false, false, null, null, 0, 6, 0);cell = row.getCell(2);setCellWidthAndVAlign(cell, "3692", STTblWidth.DXA, STVerticalJc.TOP);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "3.事件发生地点:", "宋体", "Times New Roman", "21", false, false, false, false, null, null, 0, 6, 0);cell = row.getCell(3);setCellWidthAndVAlign(cell, "0", STTblWidth.AUTO, STVerticalJc.TOP);mergeCellsHorizontal(table, 1, 2, 3);row = table.getRow(2);setRowHeight(row, "657", STHeightRule.AT_LEAST);cell = row.getCell(0);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "4.在场相关人员:", "宋体", "Times New Roman","21", false, false, false, false, null, null, 0, 6, 0);mergeCellsHorizontal(table, 2, 0, 3);row = table.getRow(3);setRowHeight(row, "387", STHeightRule.AT_LEAST);cell = row.getCell(0);setCellShdStyle(cell, true, "FFFFFF", null);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "B.不良事件情况 ﹡", "宋体", "Times New Roman","24", true, false, false, false, null, null, 0, 6, 0);mergeCellsHorizontal(table, 3, 0, 3);row = table.getRow(4);setRowHeight(row, "1613", STHeightRule.AT_LEAST);cell = row.getCell(0);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "5.事件主要表现:", "宋体", "Times New Roman","21", false, false, false, false, null, null, 0, 6, 0);mergeCellsHorizontal(table, 4, 0, 3);row = table.getRow(5);setRowHeight(row, "369", STHeightRule.AT_LEAST);cell = row.getCell(0);setCellShdStyle(cell, true, "FFFFFF", null);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "C.不良事件类别 ﹡", "宋体", "Times New Roman","24", true, false, false, false, null, null, 0, 6, 0);mergeCellsHorizontal(table, 5, 0, 3);row = table.getRow(6);cell = row.getCell(0);p = getCellFirstParagraph(cell);setParagraphSpacingInfo(p, true, "0", "0", "0", "0", true, "300",STLineSpacingRule.AUTO);setParagraphAlignInfo(p, ParagraphAlignment.BOTH, TextAlignment.CENTER);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunSymInfo(p, pRun, "宋体", "Times New Roman", "21", true,false, false, 0, 6, 0);setParagraphRunFontInfo(p, pRun, "××××××××××××××××××××××××××××", "宋体","Times New Roman", "21", true, false, false, false, null, null,0, 6, 0);setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");cell = row.getCell(2);p = getCellFirstParagraph(cell);setParagraphSpacingInfo(p, true, "0", "0", "0", "0", true, "300",STLineSpacingRule.AUTO);setParagraphAlignInfo(p, ParagraphAlignment.BOTH, TextAlignment.CENTER);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunSymInfo(p, pRun, "宋体", "Times New Roman", "21", true,false, false, 0, 6, 0);setParagraphRunFontInfo(p, pRun, "××××××××××××××××××××××××××××", "宋体","Times New Roman", "21", true, false, false, false, null, null,0, 6, 0);setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");setCellContentCommonFunction(cell, "××××××××××××××××××××××××××××");mergeCellsHorizontal(table, 6, 0, 1);mergeCellsHorizontal(table, 6, 2, 3);row = table.getRow(7);setRowHeight(row, "467", STHeightRule.AT_LEAST);cell = row.getCell(0);setCellShdStyle(cell, true, "FFFFFF", null);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "D.不良事件的等级 *", "宋体","Times New Roman", "24", true, false, false, false, null, null,0, 6, 0);mergeCellsHorizontal(table, 7, 0, 3);row = table.getRow(8);setRowHeight(row, "467", STHeightRule.AT_LEAST);cell = row.getCell(0);setCellShdStyle(cell, true, "FFFFFF", null);p = getCellFirstParagraph(cell);setParagraphAlignInfo(p, ParagraphAlignment.CENTER,TextAlignment.CENTER);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunSymInfo(p, pRun, "宋体", "Times New Roman", "28", true,false, false, 0, 6, 0);setParagraphRunFontInfo(p, pRun, "Ⅰ级事件", "宋体", "Times New Roman", "28",true, false, false, false, null, null, 0, 6, 0);pRun = getOrAddParagraphFirstRun(p, true, false);setParagraphRunSymInfo(p, pRun, "宋体", "Times New Roman", "28", true,false, false, 0, 6, 0);setParagraphRunFontInfo(p, pRun, "Ⅱ级事件     ", "宋体", "Times New Roman","28", true, false, false, false, null, null, 0, 6, 0);pRun = getOrAddParagraphFirstRun(p, true, false);setParagraphRunSymInfo(p, pRun, "宋体", "Times New Roman", "28", true,false, false, 0, 6, 0);setParagraphRunFontInfo(p, pRun, "Ⅲ级事件 ", "宋体", "Times New Roman","28", true, false, false, false, null, null, 0, 6, 0);pRun = getOrAddParagraphFirstRun(p, true, false);setParagraphRunSymInfo(p, pRun, "宋体", "Times New Roman", "28", true,false, false, 0, 6, 0);setParagraphRunFontInfo(p, pRun, "Ⅳ级事件 ", "宋体", "Times New Roman","28", true, false, false, false, null, null, 0, 6, 0);mergeCellsHorizontal(table, 8, 0, 3);row = table.getRow(9);setRowHeight(row, "467", STHeightRule.AT_LEAST);cell = row.getCell(0);setCellShdStyle(cell, true, "FFFFFF", null);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "E.事件发生的影响 *", "宋体","Times New Roman", "24", true, false, false, false, null, null,0, 6, 0);mergeCellsHorizontal(table, 9, 0, 3);row = table.getRow(10);setRowHeight(row, "722", STHeightRule.AT_LEAST);mergeCellsHorizontal(table, 10, 0, 3);row = table.getRow(11);setRowHeight(row, "427", STHeightRule.AT_LEAST);cell = row.getCell(0);setCellShdStyle(cell, true, "FFFFFF", null);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "F.事件发生后及时处理与分析 *", "宋体","Times New Roman", "24", true, false, false, false, null, null,0, 6, 0);mergeCellsHorizontal(table, 11, 0, 3);row = table.getRow(12);setRowHeight(row, "936", STHeightRule.AT_LEAST);cell = row.getCell(0);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "立即通知的人员:", "宋体", "Times New Roman","21", false, false, false, false, null, null, 0, 6, 0);mergeCellsHorizontal(table, 12, 0, 3);row = table.getRow(13);setRowHeight(row, "936", STHeightRule.AT_LEAST);cell = row.getCell(0);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "可能相关的因素:", "宋体", "Times New Roman","21", false, false, false, false, null, null, 0, 6, 0);mergeCellsHorizontal(table, 13, 0, 3);row = table.getRow(14);setRowHeight(row, "936", STHeightRule.AT_LEAST);cell = row.getCell(0);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "立即采取的措施:", "宋体", "Times New Roman","21", false, false, false, false, null, null, 0, 6, 0);mergeCellsHorizontal(table, 14, 0, 3);row = table.getRow(15);setRowHeight(row, "936", STHeightRule.AT_LEAST);cell = row.getCell(0);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "事件处理情况:", "宋体", "Times New Roman","21", false, false, false, false, null, null, 0, 6, 0);mergeCellsHorizontal(table, 15, 0, 3);row = table.getRow(16);setRowHeight(row, "460", STHeightRule.AT_LEAST);cell = row.getCell(0);setCellShdStyle(cell, true, "FFFFFF", null);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "G.不良事件评价(主管部门填写) *", "宋体","Times New Roman", "24", true, false, false, false, null, null,0, 6, 0);mergeCellsHorizontal(table, 16, 0, 3);row = table.getRow(17);setRowHeight(row, "580", STHeightRule.AT_LEAST);cell = row.getCell(0);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "主管部门意见陈述:", "宋体", "Times New Roman","21", false, false, false, false, null, null, 0, 6, 0);mergeCellsHorizontal(table, 17, 0, 3);row = table.getRow(18);setRowHeight(row, "1157", STHeightRule.AT_LEAST);cell = row.getCell(0);setCellShdStyle(cell, true, "FFFFFF", null);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "H.持续改进措施(主管部门填写) *", "宋体","Times New Roman", "24", true, false, false, false, null, null,0, 6, 0);mergeCellsHorizontal(table, 18, 0, 3);row = table.getRow(19);setRowHeight(row, "457", STHeightRule.AT_LEAST);cell = row.getCell(0);setCellShdStyle(cell, true, "FFFFFF", null);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "I.选择性填写项目(Ⅰ、Ⅱ级事件必填 *,Ⅲ、Ⅳ级事件建议填写)","宋体", "Times New Roman", "24", true, false, false, false, null,null, 0, 6, 0);mergeCellsHorizontal(table, 19, 0, 3);row = table.getRow(20);setRowHeight(row, "567", STHeightRule.AT_LEAST);cell = row.getCell(0);p = getCellFirstParagraph(cell);pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "报 告 人:    行政后勤人员 ", "宋体","Times New Roman", "21", false, false, false, false, null,null, 0, 6, 0);pRun = getOrAddParagraphFirstRun(p, true, false);setParagraphRunSymInfo(p, pRun, "宋体", "Times New Roman", "21", true,false, false, 0, 6, 0);pRun = getOrAddParagraphFirstRun(p, true, false);setParagraphRunFontInfo(p, pRun, "其他  ", "宋体", "Times New Roman","21", false, false, false, false, null, null, 0, 6, 0);pRun = getOrAddParagraphFirstRun(p, true, false);setParagraphRunSymInfo(p, pRun, "宋体", "Times New Roman", "21", true,false, false, 0, 6, 0);p = cell.addParagraph();pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "当事人的类别:本院", "宋体", "Times New Roman","21", false, false, false, false, null, null, 0, 6, 0);pRun = getOrAddParagraphFirstRun(p, true, false);setParagraphRunSymInfo(p, pRun, "宋体", "Times New Roman", "21", true,false, false, 0, 6, 0);pRun = getOrAddParagraphFirstRun(p, true, false);setParagraphRunFontInfo(p, pRun, "    其他 ", "宋体", "Times New Roman","21", false, false, false, false, null, null, 0, 6, 0);pRun = getOrAddParagraphFirstRun(p, true, false);setParagraphRunSymInfo(p, pRun, "宋体", "Times New Roman", "21", true,false, false, 0, 6, 0);p = cell.addParagraph();pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p, pRun, "职    称:    高级 ", "宋体","Times New Roman", "21", false, false, false, false, null,null, 0, 6, 0);pRun = getOrAddParagraphFirstRun(p, true, false);setParagraphRunSymInfo(p, pRun, "宋体", "Times New Roman", "21", true,false, false, 0, 6, 0);pRun = getOrAddParagraphFirstRun(p, true, false);setParagraphRunFontInfo(p, pRun, "    中级 ", "宋体", "Times New Roman","21", false, false, false, false, null, null, 0, 6, 0);pRun = getOrAddParagraphFirstRun(p, true, false);setParagraphRunSymInfo(p, pRun, "宋体", "Times New Roman", "21", true,false, false, 0, 6, 0);pRun = getOrAddParagraphFirstRun(p, true, false);setParagraphRunFontInfo(p, pRun, "    初级 ", "宋体", "Times New Roman","21", false, false, false, false, null, null, 0, 6, 0);pRun = getOrAddParagraphFirstRun(p, true, false);setParagraphRunSymInfo(p, pRun, "宋体", "Times New Roman", "21", true,false, false, 0, 6, 0);pRun = getOrAddParagraphFirstRun(p, true, false);setParagraphRunFontInfo(p, pRun, "   其他 ", "宋体", "Times New Roman","21", false, false, false, false, null, null, 0, 6, 0);pRun = getOrAddParagraphFirstRun(p, true, false);setParagraphRunSymInfo(p, pRun, "宋体", "Times New Roman", "21", true,false, false, 0, 6, 0);p = cell.addParagraph();p = cell.addParagraph();pRun = getOrAddParagraphFirstRun(p, false, false);setParagraphRunFontInfo(p,pRun,"报告人签名:         科室:         联系电话:             Email:           ","宋体", "Times New Roman", "21", false, false, false, false,null, null, 0, 6, 0);mergeCellsHorizontal(table, 20, 0, 3);saveDocument(xdoc, "f:/" + System.currentTimeMillis()+ ".docx");}

JAVA生成word中有Excel文档相关推荐

  1. php word excel,PHP 生成word 和 excel 文档

    xmlns="http://www.w3.org/TR/REC-html40"> word 中要显示的内容, 由于word支持html格式, 所以中间这一部分使用html文档 ...

  2. word、excel文档内容更新技术方案

    需求背景 惯例先说下背景. 生产.研发业务上往往使用大量word和excel文档来作为资料载体,如操作规程.控制手册.卡片--,这些文档会反复使用到一些设备.工艺等参数数据.参数属性主要是名称.编码. ...

  3. java生成自己的Doc文档

    java生成自己的Doc文档 第一种通过命令行来生成 简要代码如下: package com.can.www;/*** @author liu* @version 1.0* @since 1.8*/ ...

  4. word插入excel文档显示图标的方法

    描述:word插入excel文档显示图标的方法 步骤: 菜单栏->插入->对象 由文件创建->浏览文件夹 勾选显示为图标->确定 文件就被插入word了

  5. 计算机无法建立word文档,(电脑中右键不能新建word和excel文档怎么办)为何电脑无法新建excle...

    电脑中右键不能新建word和excel文档怎么办 开始,找到运行命,输入regedit,打开注册表. 在左侧找到hkey_classes_root目录,并展开. 首先,我们利用ctrl f 快捷键,查 ...

  6. libreoffice python 操作word及excel文档

    1.开始.关闭libreoffice服务: 开始之前同步字体文件时间,是因为创建soffice服务时,服务会检查所需加载的文件的时间,如果其认为时间不符,则其可能会重新加载,耗时较长,因此需事先统一时 ...

  7. Swagger导出word和excel文档

    之前写了篇关于Swagger2的博文 Swagger2生成在线接口文档并导出pdf文件,可以把swagger在线接口文档导出成pdf文件本地查看,当然swagger2本身是支持导出markdown格式 ...

  8. java 读取excel 图片_利用Java+POI 读写Excel文档向Excel中插入图片

    一.POI简介 Jakarta POI 是apache的子项目,目标是处理ole2对象.它提供了一组操纵Windows文档的Java API 目前比较成熟的是HSSF接口,处理MS Excel(97- ...

  9. libreoffice python_libreoffice python 操作word及excel文档的方法

    1.开始.关闭libreoffice服务: 开始之前同步字体文件时间,是因为创建soffice服务时,服务会检查所需加载的文件的时间,如果其认为时间不符,则其可能会重新加载,耗时较长,因此需事先统一时 ...

最新文章

  1. 单片机数据转换php,51单片机之数据转移指令MOV、MOVX、MOVC等
  2. VoiceConvert/音频格式快速转换
  3. ajax 延迟显示加载中提示
  4. ip访问 webstorem_常见问题-iOS WebView IP直连 如何处理 Cookie
  5. 第三章 最小化SpringXml 配置
  6. VM中Windows server 2012 R2系统安装SQL SERVER 2012的安装步骤
  7. .NET Framework 4.8发布
  8. android显示过程,Android 桌面加载图标过程分析
  9. 原码、反码、补码,以及负数的位操作
  10. 原生js 样式的操作整理
  11. 在Ubuntu10.10下安装osd-lyrics
  12. js实现删除文章弹窗提示是否确认
  13. toolchain - 工具链
  14. Crackme之Acid burn.exe
  15. 民谣歌手花粥被曝侵权新闻事件数据分析
  16. Opencv(C++)系列学习---opencv_contrib安装
  17. 智能车竞赛技术报告 | 全向行进组 - 东北林业大学- 进取号E
  18. Play with OSM (by quqi99)
  19. jva基础知识总结(二)多线程实现
  20. 华为博士招聘上机考试题目_华为校园招聘上机考试题

热门文章

  1. 橘子学ES03之Docker安装ELK+cerebro
  2. 用python根据生日判断星座_求指教,我这个 代码是实现 根据生日判断星座
  3. 如何把一个字符串的大小写取反?(大写转小写/小写转大写)
  4. 软件工程导论第六版 第一章 软件工程学概述知识点总结(下)
  5. mezzanine用户扩展/PUBLIC USER ACCOUNTS(一)
  6. 学习SEO就到SEOWHY,SEO十万个为什…
  7. 非常详细的Docker学习教程
  8. 小程序开发——页面背景色设置
  9. 打造国内专业企业研发管理解决方案,ONES完成华创资本领投A+轮600万美元融资
  10. 从FrameDebugger看Unity渲染