FAQ Database Discussion Community

how to set cell style without HSSFWorkbook instance?

I wanted to set font of the title row in a spreadsheet bold. I was able to do that in my main function with the following code: HSSFWorkbook workbook = new HSSFWorkbook(); HSSFSheet dataSheet = workbook.createSheet("Data"); HSSFCellStyle fontStyle = workbook.createCellStyle(); HSSFFont font = workbook.createFont(); font.setBold(true); fontStyle.setFont(font); Row row = dataSheet.createRow(0);...

CellStyle dataformat for XLSX

I have some code like : CellStyle cs2 = wb.createCellStyle(); CellStyle cs4 = wb.createCellStyle(); cs4.setDataFormat(HSSFDataFormat.getBuiltinFormat("CELL_TYPE_NUMERIC")); cs2.setDataFormat(HSSFDataFormat.getBuiltinFormat("text")); this is for creating xls reports. How do i change this code to create XLSX reports ? will the following work ? XSSFDataFormat format = (XSSFDataFormat) wb.createDataFormat(); cs2.setDataFormat(format.getFormat("text")); Please help. Thanks...