title: NPOI/POI Help in C#, setformula error
body: <p>I am trying to do a large, match and index on an excel file I read from. Large works fine but It throws an error on the Match line. If i hardcode <code>K = an int</code>, it works just fine.</p>
  
  <p>Current error:</p>
  
  <blockquote>
    <p>An exception of type 'System.InvalidOperationException' occurred in NPOI.dll but was not handled in user code</p>
  </blockquote>
  
  <p>I am doing a large, match and index to find top 4 of a list of unsorted rows, i want the associated values to go with them. My logic works just fine in vba or hard coding</p>
  
  <p>Additional information: Cannot get a numeric value from a error formula cell</p>
  
  <p>My ranges are <code>C10:C30</code> and <code>K10:K30</code>, both ranges are right. </p>
  
  <pre><code>string cellrange = new CellRangeAddress(firstrow + 1, sheet1.LastRowNum, 10, 10).ToString();
  string cellsrange = cellrange.Remove(0, 18);
  string cellsranges = cellsrange.Remove(cellsrange.Length - 1, 1);
  
  string states = new CellRangeAddress(firstrow + 1, sheet1.LastRowNum, 2, 2).ToString();
  string statesrange = states.Remove(0, 18);
  string statesranges = statesrange.Remove(statesrange.Length - 1, 1);
  
  for (int row = 1; row &lt;= 4; row++)
  {
      sheet1.CreateRow(row + firstrow + 1).CreateCell(15).SetCellFormula("LARGE(" + cellsranges + "," + row + ")");
      HSSFFormulaEvaluator.EvaluateAllFormulaCells(hssfwb);
  
      double j = sheet1.GetRow(row + firstrow + 1).GetCell(15).NumericCellValue;
  
      sheet1.CreateRow(row + firstrow + 1).CreateCell(16).SetCellFormula("MATCH(" + j + "," + cellsranges + ", " + 0 + ")");
      HSSFFormulaEvaluator.EvaluateAllFormulaCells(hssfwb);
  
      double k = sheet1.GetRow(row + firstrow + 1).GetCell(16).NumericCellValue;
  
      sheet1.CreateRow(row + firstrow + 1).CreateCell(17).SetCellFormula("INDEX(" + statesranges + "," + k + "," + 1 + ")");
      HSSFFormulaEvaluator.EvaluateAllFormulaCells(hssfwb);
  
      string stateperc = sheet1.GetRow(row + firstrow+1).GetCell(17).StringCellValue + "-" + j.ToString();
  
      MessageBox.Show(stateperc);
  }
  </code></pre>