【发布时间】:2022-02-01 07:07:10
【问题描述】:
如何在使用 Apache POI 创建 docx 文件时格式化表格。我想设置单元格的大小、文本的字体、颜色等。
我找到了这个例子,但是单元格大小是根据文本大小设置的。
XWPFDocument document = new XWPFDocument();
// New 2x2 table
XWPFTable tableOne = document.createTable();
XWPFTableRow tableOneRowOne = tableOne.getRow(0);
tableOneRowOne.getCell(0).setText("Hello");
tableOneRowOne.addNewTableCell().setText("World");
XWPFTableRow tableOneRowTwo = tableOne.createRow();
tableOneRowTwo.getCell(0).setText("This is");
tableOneRowTwo.getCell(1).setText("a table");
我想使表格居中并增加单元格大小。
【问题讨论】:
标签: apache-poi docx