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);
XSSFWorkbook wbOut = new XSSFWorkbook(); CellStyle style = wbOut.createCellStyle();style.setVerticalAlignment(HSSFCellStyle.VERTICAL_TOP);cell.setCellStyle(style);