[英]How to change font color in Apache POI word document on a specific table cell without using paragraph and run?
我已经创建了一种根据某些条件格式化表格单元格的方法,问题是使用段落并运行它会在单元格内创建新行,而这是我所不希望的。
private void setTab1CellValue(XWPFTable table, int r, int c, String label, BigInteger condition, String value) {
table.getRow(r).getCell(c).setText(label);
if (value != null) {
if (condition != null && condition.equals(BigInteger.ONE)) {
XWPFParagraph paragraph = table.getRow(r).getCell(c + 1).addParagraph();
XWPFRun run = paragraph.createRun();
run.setColor("FF0000");
run.setText(value);
} else {
table.getRow(r).getCell(c + 1).setText(value);
}
}
}
还有其他方法可以使我修改上面的代码以更改单元格的字体颜色,而无需使用段落和运行(或在单元格内没有换行符)?
请帮忙。 提前致谢。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.