@Override
public HorizontalAlignment getAlignment() {
+ if(!_cellXf.getApplyAlignment()) return HorizontalAlignment.GENERAL;
+
CTCellAlignment align = _cellXf.getAlignment();
if(align != null && align.isSetHorizontal()) {
return HorizontalAlignment.forInt(align.getHorizontal().intValue()-1);
@Override
public VerticalAlignment getVerticalAlignment() {
+ if(!_cellXf.getApplyAlignment()) return VerticalAlignment.BOTTOM;
+
CTCellAlignment align = _cellXf.getAlignment();
if(align != null && align.isSetVertical()) {
return VerticalAlignment.forInt(align.getVertical().intValue()-1);
*/
@Override
public void setAlignment(HorizontalAlignment align) {
+ _cellXf.setApplyAlignment(true);
+
getCellAlignment().setHorizontal(align);
}
* @param align - the type of alignment
*/
public void setVerticalAlignment(VerticalAlignment align) {
+ _cellXf.setApplyAlignment(true);
+
getCellAlignment().setVertical(align);
}
}
@Test
- public void test64986() throws IOException {
+ public void test64986() {
XSSFWorkbook w = new XSSFWorkbook();
XSSFSheet s = w.createSheet();
XSSFRow r = s.createRow(0);
assertNotNull(wb);
}
}
+
+ @Test
+ public void test64494() throws IOException {
+ try (Workbook wb = new XSSFWorkbook()) {
+ CellStyle styleRight = wb.createCellStyle();
+ CellStyle styleLeft = wb.createCellStyle();
+ styleRight.setAlignment(HorizontalAlignment.RIGHT);
+ //styleRight.setBorderBottom(BorderStyle.DASH_DOT);
+ styleLeft.setAlignment(HorizontalAlignment.LEFT);
+ //styleLeft.setBorderRight(BorderStyle.MEDIUM);
+
+ assertEquals(HorizontalAlignment.RIGHT, styleRight.getAlignment());
+ assertEquals(HorizontalAlignment.LEFT, styleLeft.getAlignment());
+
+ Sheet sheet = wb.createSheet("test");
+ Row row = sheet.createRow(0);
+
+ Cell cellRight = row.createCell(0);
+ cellRight.setCellValue("R");
+ cellRight.setCellStyle(styleRight);
+
+ Cell cellLeft = row.createCell(1);
+ cellLeft.setCellValue("L");
+ cellLeft.setCellStyle(styleLeft);
+
+ /*try (OutputStream out = new FileOutputStream("/tmp/64494.xlsx")) {
+ wb.write(out);
+ }*/
+
+ assertEquals(HorizontalAlignment.RIGHT, cellRight.getCellStyle().getAlignment());
+ assertEquals(HorizontalAlignment.LEFT, cellLeft.getCellStyle().getAlignment());
+ }
+ }
}