title: How to override cell style in excel file using java and Apache POI library?
body: <p>I am doing excel validations for input .xlsx file using java and Apache POI library. </p>
  
  <p>Here below I am posting two functions from my java class. When I try to set the cell style it's not getting reflected in the excel file. I searched over internet about it, but everywhere they have given code to give style while creating cell/row itself.</p>
  
  <pre><code>public static CellStyle getNewCellStyle(){
      CellStyle style = myWorkBook.createCellStyle();
      style.setFillBackgroundColor(IndexedColors.GREEN.getIndex());
      style.setFillPattern(CellStyle.ALIGN_FILL); 
      return style;
  }
  
  
  public static void chCaseNumberColumnValidation(Cell cell){
      String cellData = getCellDataValue(cell);
      if(cellData.length() == 10){
          if(cellData.equals("BLANK") || cellData.trim().length() == 0){
              System.out.println("BLANK CELL:   " + cell.getRowIndex() + "," + cell.getColumnIndex());
          }
  
          if(cellData.charAt(0) != '5'){
              System.out.println("DON't START WITH 5:    " + cell.getRowIndex() + "," + cell.getColumnIndex());
              cell.setCellStyle(getNewCellStyle());
          }
      }
      else{
          System.out.println("****INVALID SIZE   " + cell.getRowIndex() + "," + cell.getColumnIndex());
  
      }
  
  }
  </code></pre>
  
  <p>Is there any way by which I can give background color to the already existing cells. (altering cell style)</p>