作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想在poi word中设置单元格垂直对齐,但我发现它不起作用,这是我的代码。这是怎么回事?
XWPFTableCell cell = table.getRow(i).getCell(j);
cell.setVerticalAlignment(XWPFTableCell.XWPFVertAlign.CENTER);
最佳答案
您无法直接设置任何单元格的对齐方式。每个单元格都包含一个段落,并且它们包含运行。所以你还需要设置它们的对齐方式。我通过以下方法实现了同样的问题。希望它也能解决你的问题。竖起大拇指:)
private static void setHeaderRowforSingleCell(XWPFTableCell cell, String text) {
XWPFParagraph tempParagraph = cell.getParagraphs().get(0);
tempParagraph.setIndentationLeft(100);
tempParagraph.setIndentationRight(100);
tempParagraph.setAlignment(ParagraphAlignment.CENTER);
XWPFRun tempRun = tempParagraph.createRun();
tempRun.setFontSize(10);
tempRun.setColor("FFFFFF");
tempRun.setText(text);
cell.setVerticalAlignment(XWPFVertAlign.CENTER);
}
关于apache-poi - 如何在poi word中设置单元格setVerticalAlignment?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43268627/
我是一名优秀的程序员,十分优秀!