setBoldweight is not working

apache-poi, java, xlsx

Solution

As per the valuable comment of Gagravarr, I have changed the code:

         Row rowhead= sheet.createRow((short)0);
         Font f = wb.createFont();
         f.setBoldweight(Font.BOLDWEIGHT_BOLD);
         CellStyle cs = wb.createCellStyle();
         cs.setFont(f);

         Cell cell;             
         cell = rowhead.createCell((short) 0);
         cell.setCellValue("SRNum");
         cell.setCellStyle(cs);

         cell = rowhead.createCell((short) 1);
         cell.setCellValue("Name");
         cell.setCellStyle(cs);

Problem

I was trying to add some styles to the excel sheet, I have generated using apache poi. Here is the code, I tried to make the first row in BOLD. ``` SXSSFWorkbook wb=new SXSSFWorkbook(); Sheet sheet = wb.createSheet("Excelx"); Row row= sheet.createRow((short)0); row.createCell((short) 0).setCellValue("SRNum"); row.createCell((short) 1).setCellValue("Name"); CellStyle cs = wb.createCellStyle(); Font f = wb.createFont(); f.setFontHeightInPoints((short) 20); f.setBoldweight(Font.BOLDWEIGHT_BOLD); cs.setFont(f); row.setRowStyle(cs); ``` But still, the first row is not changing to BOLD.

Original source