String path = "C:\\Users\\Desktop\\"; File file = new File(path + "a.png"); byte[] bytes = new byte[(int) file.length()]; FileInputStream fis = new FileInputStream(file); fis.read(bytes); fis.close(); XWPFDocument document = new XWPFDocument(); int rows = 14; int cols = 3; int fontSize = 14; XWPFTable table = document.createTable(rows, cols); for (int row = 0; row < rows; row++) { for (int col = 0; col < cols; col++) { XWPFTableCell cell = table.getRow(row).getCell(col); XWPFParagraph p = new XWPFParagraph(cell.getCTTc().addNewP(), cell); cell.setParagraph(p); XWPFParagraph paragraph = cell.getParagraphs().get(0); //字体位置设置 paragraph.setAlignment(ParagraphAlignment.LEFT); cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER); //字体大小设置 XWPFRun run = paragraph.createRun(); run.setFontSize(fon
06-04
3757
12-21