This Code Snippet throws light on the following POI features:
1) Set Row Height
2) Freeze Pane
3) Set Column Width
4) Align the Contents of the Cell
5) Set Foreground Color
1) Set Row Height
2) Freeze Pane
3) Set Column Width
4) Align the Contents of the Cell
5) Set Foreground Color
//Create new workbook wb = new HSSFWorkbook(); //Create a new sheet Sheet sheet = wb.createSheet("Formatting_Test"); //Create a new row Row hRow = sheet.createRow(0); //Set height if you need - optional hRow.setHeightInPoints(7.25f); //Use this statement to freeze pane the row created - optional sheet.createFreezePane(0, 1); //Create a new cell Cell hCell = hRow.createCell(0); //For setting the Column width - optional //The width is in units of 1/256th of a character width //So, 256*6 will be 6 character widths sheet.setColumnWidth(0, 256*6); //Center Alignment - optional hCell.setAlignment(CellStyle.ALIGN_CENTER); //Setting blue color as BG color - optional hCell.setFillForegroundColor(IndexedColors.BLUE.getIndex());