阿帕奇 POI - CellStyle.ALIGN_RIGHT

Apache POI - CellStyle.ALIGN_RIGHT

我正在尝试对齐文本。 这是我的 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) ,我得到了这个编译错误:

也许您正在寻找

cellStyle.setAlignment(HorizontalAlignment.RIGHT);
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);