title: create a spreadsheet and have cells with colored background using the NPOI library
body: <p>I am trying to create an Excel spreadsheet from a vb.net application using the NPOI library.  I am using the following code:</p>
  
  <pre><code>Imports NPOI.HSSF.UserModel
  Imports NPOI.SS.UserModel
  Imports NPOI.SS.Util
  Imports NPOI.HSSF.Util
  Imports NPOI.POIFS.FileSystem
  Imports NPOI.HPSF
  Imports NPOI.HSSF.Util.HSSFColor
  
  'create a background color of red
  Dim styleCellRedBackGround As HSSFCellStyle = workbook.CreateCellStyle()
  styleCellRedBackGround.FillBackgroundColor = NPOI.HSSF.Util.HSSFColor.RED.index
  Dim styleCellRedBackGroundFont = workbook.CreateFont()
  styleCellRedBackGroundFont.FontName = "Red Background"
  styleCellRedBackGround.SetFont(styleCellRedBackGroundFont)
  
  row = sheet.CreateRow(2)
  cell = row.CreateCell(0)
  cell.CellStyle = styleCellRedBackGround
  cell.SetCellValue("&lt;&lt;COMPETITIVE REBATES&gt;&gt;")
  </code></pre>
  
  <p>The spreadsheet gets created, but there is no red background for the cell.  If I create a cell and specify the red background, but do not write anything to the cell, this seems to work.  There seems to be limited documentation on how to do this.  Any suggestions?</p>
  
  <p>Thanks</p>