title: C# Excel : Correct way to get Rows and Columns count
body: <p>I have problem with C# Interop Excel get valid range with big file  </p>
  
  <p><a href="https://www.dropbox.com/s/betci638b1faw8g/Demo%20Training%20Data.xlsx?dl=0" rel="noreferrer">https://www.dropbox.com/s/betci638b1faw8g/Demo%20Training%20Data.xlsx?dl=0</a></p>
  
  <p>This is my file but real size is 1000 but I got 49998</p>
  
  <p>I used standard code</p>
  
  <pre><code>Excel.Application xlApp = new Excel.Application();
  Excel.Workbook xlWorkbook = xlApp.Workbooks.Open(txtbTrainPath.Text);
  Excel.Worksheet xlWorksheet = xlWorkbook.Worksheets[1];
  Excel.Range xlRange = xlWorksheet.UsedRange;              
  xlApp.Visible = true;
  xlWorksheet.Columns[5].Delete();
  xlWorksheet.Columns[3].Delete();              
  rowCount = xlRange.Rows.Count;
  colCount = xlRange.Columns.Count;
  </code></pre>
  
  <p>Only for this file is not work correctly, other files works well. Please help me to find what is the problem. How to resize worksheet for only valid size.</p>