title: JSF -Set global font type for the excel sheet in JSF using HSSFFont in Apache POI
body: <p>I have an option to export the datatable to an excel sheet.<br/>
  I am tryin to set the font type as "Calibri"  for all the cell in the sheet.<br/>
  But the below code is assigning only the font type for the header not for the rest of the cells<br/>
  <strong>How can I able to set the font type globally for all the cell in the sheet ?</strong> <br/></p>
  
  <pre><code>  public void exportToXLS(Object document) {
  
          HSSFWorkbook wb = (HSSFWorkbook) document;
          HSSFSheet sheet = wb.getSheetAt(0);
          wb.setSheetName(0, "report_lists"); // set sheet name
          sheet.shiftRows(0, sheet.getLastRowNum(), 4); // shifting the rows to
          HSSFRow header = sheet.getRow(4);
          header.getCell(1).setCellValue("Test Group");
          header.getCell(2).setCellValue("Category");
  
          HSSFRow firstrow = sheet.getRow(0);
          firstrow.createCell(0).setCellValue("Actuals");
  
          SimpleDateFormat sdf = new SimpleDateFormat(
                  "EEE MMM d HH:mm:ss 'CDT'  yyyy ");
          Date date = new Date();
          sdf.setTimeZone(TimeZone.getTimeZone("GMT-5"));
          String reportDate = sdf.format(date);
          HSSFRow thirdrow = sheet.getRow(3);
          thirdrow.createCell(0).setCellValue(reportDate);
  
          HSSFCellStyle cellStyle = wb.createCellStyle();
          cellStyle.setFillForegroundColor(HSSFColor.YELLOW.index);
          cellStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
          HSSFFont fontHeader = (HSSFFont) wb.createFont();
          fontHeader.setFontName("Calibri");
          cellStyle.setFont(fontHeader);
          System.out.println(" header.getPhysicalNumberOfCells();::::"
                  + header.getPhysicalNumberOfCells());
  
          //only for changing font for header
          for (int i = 0; i &lt; header.getPhysicalNumberOfCells(); i++) {
              HSSFCell cell = header.getCell(i);
              cell.setCellStyle(cellStyle);
              // sheet.setDefaultColumnStyle(i, cellStyle);
  
          }
          System.out.println("sheet.getLastRowNum():::" + sheet.getLastRowNum());
          for (int j = 1; j &lt; sheet.getPhysicalNumberOfRows(); j++) {
              HSSFRow row = sheet.getRow(j);
              if (row != null) {
                  System.out.println(" j&gt;&gt;&gt;" + j);
                  // you can add sysout or debug here to check if all row passed
                  // successfully
                  for (int i = 0; i &lt; row.getPhysicalNumberOfCells(); i++) {
                      HSSFCell cell = row.getCell(i);
                      if (cell != null) {
                          System.out.println(" i++" + i);
                          // you can add sysout or debug here to check if all cell
                          // passed successfully
                          HSSFCell celll = header.getCell(i);
                          celll.setCellStyle(cellStyle);
                      }
                  }
              }
          }
  
  
      }
  </code></pre>
  
  <p><br/>
  Here is the screen shot of the excel:<br/>
  <img src="https://i.stack.imgur.com/iG3kT.jpg" alt="enter image description here"></p>