title: How to set excel cell background color with System color in NPOI
body: <p>I have an object of class <code>Foo</code> with attribute <code>StatusColor</code> being used in multiple locations.
  Now, I have to generate an Excel file using NPOI in which the column <code>Status Color</code> should have the same color as the object.</p>
  
  <p>I do not know how to set <code>System.Drawing.Color</code> as CellStyle color, please help.</p>
  
  <p>I would like something like:</p>
  
  <pre><code>class Foo{
      //Properties..
      System.Drawing.Color StatusColor {get;set;}
  }
  
  ...
  
  //Creating Status Style
  var statusStyle = workbook.CreateCellStyle();
  statusStyle.FillForegroundColor = fooObject.StatusColor; //Of course, it won't work.
  //Is there way to convert from System.Color to HSSFColor?
  statusStyle.FillPattern = FillPattern.SolidForeground;
  
  ...
  
  //Set Style
  excelCell.CellStyle = style;
  </code></pre>
  
  <p><strong>In-Short:</strong> 
  How can I convert <code>System.Drawing.Color</code> into <code>HSSFColor</code> color index?</p>
  
  <p><strong>I tried:</strong>
  I have written a function to convert (from <code>Color</code> to <code>HSSFColor</code> index), but not sure how many <code>if-else</code> have to be written.</p>
  
  <pre><code>public static short ToHSSFColorIndex(Color color)
  {
      if (Color.Green.ToArgb().Equals(color.ToArgb()))
          return HSSFColor.Green.Index;
      else if (Color.Green.ToArgb().Equals(color.ToArgb()))
          return HSSFColor.LightGreen.Index;
      else if (Color.Red.ToArgb().Equals(color.ToArgb()))
          return HSSFColor.Red.Index;
      else if (Color.DarkRed.ToArgb().Equals(color.ToArgb()))
          return HSSFColor.DarkRed.Index;
      else if (Color.Gray.ToArgb().Equals(color.ToArgb()))
          return HSSFColor.Grey50Percent.Index;
      else if (Color.Blue.ToArgb().Equals(color.ToArgb()))
          return HSSFColor.Blue.Index;
      else if (Color.Yellow.ToArgb().Equals(color.ToArgb()))
          return HSSFColor.Yellow.Index;
      else if (Color.YellowGreen.ToArgb().Equals(color.ToArgb()))
          return HSSFColor.LightYellow.Index;
      else if (Color.White.ToArgb().Equals(color.ToArgb()))
          return HSSFColor.White.Index;
      else
          return HSSFColor.COLOR_NORMAL;
  }
  </code></pre>