title: Java code for excel row in Bold text style with Background color
body: <p>I have googled some code and found some answers but not able to get my excel file output in Bold and set background color. I have tried with following code. can you please tell me where am I going wrong? Please take a look. Thanks.</p>
  
  <blockquote>
    <p>FYI: I am going to make 1st Row in BOLD with blue or any Light color
    background. If you know please help with the code.</p>
  </blockquote>
  
  <pre><code>// Excel file generation code
  HSSFWorkbook workbook = new HSSFWorkbook();
  HSSFSheet sheet = workbook.createSheet("Readings");
  CellStyle style = workbook.createCellStyle();
  Font font = workbook.createFont();
  font.setFontHeightInPoints((short)11);
  font.setFontName(HSSFFont.FONT_ARIAL);
  font.setBoldweight(HSSFFont.COLOR_NORMAL);
  font.setBold(true);
  font.setColor(HSSFColor.DARK_BLUE.index);
  
  style.setFont(font);
  // Freeze 1st Row               
  sheet.createFreezePane(0, 1); 
  
  HSSFRow row = sheet.createRow(1);
  HSSFRow rowhead = sheet.createRow((short) 0);
  rowhead.setRowStyle(style);
  
  rowhead.createCell(0).setCellValue("RUN");
  rowhead.createCell(1).setCellValue("NUMBER");
  </code></pre>