1.

How Will You Style A Cell Using Apache Poi?

Answer»

XSSFCellStyle class is USED to style a cell. Following CODE snippet can be used to set the cell ALIGNMENT to "Top Left".

XSSFCellStyle style1 = workbook.createCellStyle();

spreadsheet.setColumnWidth(0, 8000);

style1.setAlignment(XSSFCellStyle.ALIGN_LEFT);

style1.setVerticalAlignment(XSSFCellStyle.VERTICAL_TOP);

cell.setCellValue("Top Left");

cell.setCellStyle(style1);

XSSFCellStyle class is used to style a cell. Following code snippet can be used to set the cell alignment to "Top Left".

XSSFCellStyle style1 = workbook.createCellStyle();

spreadsheet.setColumnWidth(0, 8000);

style1.setAlignment(XSSFCellStyle.ALIGN_LEFT);

style1.setVerticalAlignment(XSSFCellStyle.VERTICAL_TOP);

cell.setCellValue("Top Left");

cell.setCellStyle(style1);



Discussion

No Comment Found