title: POI Set foreground color not working in if statement
body: <p>I am doing some code that compares two sheets and outputs a file with the matching cells in green and the others in red.</p>
  
  <p><strong>Problematic section (see full code at the end)</strong></p>
  
  <pre><code>CellStyle style = cellOutputFile.getCellStyle();
  
  if (isCellContentEqual(cellComparisonFile1, cellComparisonFile2) == true)
  {
      style.setFillForegroundColor(IndexedColors.GREEN.getIndex());
  }
  else
  {
      style.setFillForegroundColor(IndexedColors.RED.getIndex());
  }
  
  style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
  cellOutputFile.setCellStyle(style);
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>This code always displays ALL cells as green, even if, when debugging, the else statement is triggered and the style is set to have a red background.</p>
  
  <p>Thanks in advance for any help!</p>
  
  <p><strong>Full Code</strong></p>
  
  <pre><code>    for (int i = 0; i &lt; workbookComparisonFile1.getNumberOfSheets(); i++)
      {
          sheetComparisonFile1 = workbookComparisonFile1.getSheetAt(i);
          sheetComparisonFile2 = workbookComparisonFile2.getSheet(sheetComparisonFile1.getSheetName());
          sheetOutputFile = workbookOutputFile.getSheet(sheetComparisonFile1.getSheetName());
  
          System.out.println(sheetComparisonFile1.getLastRowNum());
  
          if (sheetComparisonFile2 != null)
          {
              for (int j = 0; j &lt; sheetComparisonFile1.getLastRowNum(); j++)
              {
                  Row rowComparisonFile1 = sheetComparisonFile1.getRow(j);
                  Row rowComparisonFile2 = sheetComparisonFile2.getRow(j);
                  Row rowOutputFile = sheetOutputFile.getRow(j);
  
                  if ((rowComparisonFile1 != null &amp;&amp; rowComparisonFile2 != null)
                          &amp;&amp; (rowComparisonFile1.getLastCellNum() == rowComparisonFile2.getLastCellNum()))
                  {
                      for (int k = 0; k &lt; rowComparisonFile1.getLastCellNum(); k++)
                      {
                          Cell cellComparisonFile1 = rowComparisonFile1.getCell(k);
                          Cell cellComparisonFile2 = rowComparisonFile2.getCell(k);
                          Cell cellOutputFile = rowOutputFile.getCell(k);
  
                          if (cellComparisonFile1 != null &amp;&amp; cellComparisonFile2 != null)
                          {
                              CellStyle style = cellOutputFile.getCellStyle();
  
                              if (isCellContentEqual(cellComparisonFile1, cellComparisonFile2) == true)
                              {
                                  style.setFillForegroundColor(IndexedColors.GREEN.getIndex());
                              }
                              else
                              {
                                  style.setFillForegroundColor(IndexedColors.RED.getIndex());
                              }
  
                              style.setFillPattern(FillPatternType.SOLID_FOREGROUND);
                              cellOutputFile.setCellStyle(style);
                          }
                      }
                  }
              }
          }
      }
  
  public boolean isCellContentEqual(Cell cell1, Cell cell2)
  {
      if (getCellContents(cell1).equals(getCellContents(cell2)) == false)
      {
          System.out.println("Sheet: " + cell1.getRow().getSheet().getSheetName() +
                  " Cell1: " + cell1.getRow().getRowNum() + "-" + cell1.getColumnIndex() + " "
                  + getCellContents(cell1).equals(getCellContents(cell2)));
      }
      return getCellContents(cell1).equals(getCellContents(cell2));
  }
  
  public String getCellContents(Cell cell)
  {
      DataFormatter df = new DataFormatter();
  
      return df.formatCellValue(cell);
  }
  </code></pre>