Apache POI - CellStyle.ALIGN_RIGHT

6

我想让文本对齐。 这是我的pom.xml文件:

<dependency>
            <groupId>org.apache.poi</groupId>
            <artifactId>poi-ooxml</artifactId>
            <version>3.17</version>
</dependency> 

在我的代码中:

import org.apache.poi.ss.usermodel.CellStyle;

但是当我想要使用它(CellStyle.ALIGN_RIGHT)时,我遇到了这个编译错误:

enter image description here


1
请提供 CellStyle.ALIGN_RIGHT 的完整用法。 - Nikolas Charalambidis
2个回答

18

也许你正在寻找

cellStyle.setAlignment(HorizontalAlignment.RIGHT);

9
XSSFFont font = workBook.createFont();
Old : font.setBoldweight(XSSFFont.BOLDWEIGHT_BOLD);
New : font.setBold(true);

also 

CellStyle style = workBook.createCellStyle();
OLD : style.setAlignment(CellStyle.ALIGN_CENTER);
New : style.setAlignment(HorizontalAlignment.CENTER);

then
style.setFont(font);

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接