title: deleting rows from an excel file using c#
body: <p>I am opening an excel file like this:</p>
  
  <pre><code>Excel.Application xlApp;
  Excel.Workbook xlWorkBook;
  Excel.Worksheet xlWorkSheet;
  Excel.Range range;
  
  string str;
  int rCnt = 0;
  int cCnt = 0;
  
  xlApp = new Excel.ApplicationClass();
  xlWorkBook = xlApp.Workbooks.Open("csharp.net-informations.xls", 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
  xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
  </code></pre>
  
  <p>I would like to know:<br>
  <strong>How do I loop through all the rows and delete every row in which the string <code>SomeString</code> does not appear in <code>column A</code>?</strong></p>
  
  <p>I know how to loop through every value:</p>
  
  <pre><code>for (rCnt = 1; rCnt &lt;= range.Rows.Count; rCnt++)
  {
      for (cCnt = 1; cCnt &lt;= range.Columns.Count; cCnt++)
      {
          str = (string)(range.Cells[rCnt, cCnt] as Excel.Range).Value2;
          MessageBox.Show(str);
      }
  }
  </code></pre>
  
  <p>But I do not know how to delete the entire row</p>