Cell vertical top alignment using poi Cell vertical top alignment using poi apache apache

Cell vertical top alignment using poi


Had this problem as well, you will be supprised but to set vertical aligment to style in POI you should use setVerticalAlignment() function not setAlignment(). Example:

XSSFCellStyle styleSubHeader = (XSSFCellStyle) wb.createCellStyle();styleSubHeader.setVerticalAlignment(CellStyle.VERTICAL_CENTER);


You can use this code :

style.setVerticalAlignment(VerticalAlignment.TOP);


XSSFWorkbook wbOut = new XSSFWorkbook();    CellStyle style = wbOut.createCellStyle();style.setVerticalAlignment(HSSFCellStyle.VERTICAL_TOP);cell.setCellStyle(style);