en Lopes
en Lopes

Reputation: 2133

Apache POI - CellStyle.ALIGN_RIGHT

I am trying to align text. Here my pom.xml:

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

in my code:

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

but when I want to use it (CellStyle.ALIGN_RIGHT) , I got this compilation error:

enter image description here

Upvotes: 6

Views: 16294

Answers (2)

Kishore
Kishore

Reputation: 91

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);

Upvotes: 9

user8654079
user8654079

Reputation:

Maybe you're looking for

cellStyle.setAlignment(HorizontalAlignment.RIGHT);

Upvotes: 18

Related Questions