public static void setTableProperties(XWPFTable table) {
// Set table width (in twentieths of a point)
CTTblPr tblPr = table.getCTTbl().getTblPr();
CTTblWidth tblWidth = tblPr.addNewTblW();
tblWidth.setW(BigInteger.valueOf(7000)); // Adjust the width as needed
// Set font and color for the entire table
for (XWPFTableRow row : table.getRows()) {
for (XWPFTableCell cell : row.getTableCells()) {
for (XWPFParagraph paragraph : cell.getParagraphs()) {
for (XWPFRun run : paragraph.getRuns()) {
run.setFontFamily("宋体"); // Set font family
run.setFontSize(12); // Set font size to 12 points (小四)
run.setColor("FF0000"); // Set font color to red
}
}
}
}
}
这段代码为啥设置字体大小和颜色不行呢,宽度倒是可以实现。