title: How to check if a cell is empty (Excel\VisualC#)
body: <p>My aim is to check line per line in the <code>Sheet1</code> in order to discover how many rows are, so i put a do\while that should stop once it reaches a blank cell</p>
  <p>Example:</p>
  <blockquote>
  <p>row1 data<br/> row2 data<br/> row3 data<br/>row4 data<br/>row5 data</p>
  <p>row6 data<br/>  row7 data<br/></p>
  </blockquote>
  <p>In this case I need only the first 5 rows, so the do\while check is intended to stop once it reaches the blank cell. This doesn't happens, because the check doesn't loop (it stops after completing a circle like it finds a blank cell even if it is filled with data).</p>
  <pre><code>string str;
  int rCnt = 11; //the data I need is after the 10th row in excel
  int cCnt = 1;
  int valori = 1;
  
  Excel.Application xlApp = new Excel.Application();
  Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(label4.Text, 0, false, 5, &quot;&quot;, &quot;&quot;, 
                                                   false, Excel.XlPlatform.xlWindows, 
                                                   &quot;&quot;, true, false, 0, true, false, 
                                                   false);
  Excel.Sheets xlsheet = xlWorkbook.Worksheets;
  string sheet1 = &quot;Sheet1&quot;;
  Excel.Worksheet xlWorksheet = (Excel.Worksheet)xlsheet.get_Item(sheet1);
  Excel.Range xlCell;   
  
  do
  {
      rCnt++;
      str = &quot;A&quot; + rCnt;
      xlCell = (Excel.Range)xlWorksheet.get_Range(str, str);
  } while (xlCell.Value2 == null);
      
  </code></pre>
  <p>I tried changing <code>Value2</code> to <code>Value</code> or <code>Text</code> and trying to set == &quot;&quot; instead of null.</p>