title: Cannot convert System.DBNull to int
body: <p>I'm struggling to work out what this issue is, I have an excel spreadsheet that has to be imported into my SQL Server Database. I iterate through it as follows:</p>
  
  <pre><code>Microsoft.Office.Interop.Excel.Range xlRange = xlWorksheet.Range["A1", "D6867"]; 
  
  int num = 4;
  // String test = "";
  foreach (Microsoft.Office.Interop.Excel.Range row in xlRange.Rows)
  {
      if ((int)xlWorksheet.Cells[num, 1].Font.Size == 14)
      {
              ProductCategory category = new ProductCategory();
              category.Category = xlWorksheet.Cells[num, 1].Value.ToString();
              db.ProductCategories.Add(category);
      }
      num++;
      //System.Diagnostics.Debug.WriteLine(test);
  } db.SaveChanges();
  xlWorkbook.Close(true, Missing.Value, Missing.Value);
  xlApp.Quit();
  </code></pre>
  
  <p>The error I'm getting is </p>
  
  <blockquote>
    <p>Cannot convert System.DBNull to int</p>
  </blockquote>
  
  <p>at this line:</p>
  
  <pre><code>if ((int)xlWorksheet.Cells[num, 1].Font.Size == 14)
  </code></pre>
  
  <p>I have no idea what this error means, and there are no null values in the cells I am accessing. Please advise?</p>