title: VB.NET - Reading ENTIRE content of an excel file
body: <p>I already know the basic procedure of how to read specific cells of an .xls file using VB.NET but I can't figure out how to automatically get all the data from such a file.</p>
  
  <p>Basically, I'm obtaining the data like this:</p>
  
  <pre><code>Dim xlApp As Excel.Application
  Dim wb As Workbook
  Dim ws As Worksheet
  xlApp = New Excel.Application
  wb = xlApp.Workbooks.Open("myfile.xls")
  ws = wb.Worksheets("worksheet1")
  For Each cell In ws.Range("A1", "C10")
       Console.WriteLine(cell.value)
  Next
  </code></pre>
  
  <p>In this case, I know that there will be content in the first 10 rows of the columns A, B and C but what would I have to do if I had a huge document whose size and content might even change from time to time? I know that there is also an attribute ws.rows.count but this always returns a big value like 60000 even if only a few rows are occupied.</p>
  
  <p>So basically, I'm looking for a simple way to loop through all the used rows of an Excel file with the possibility of accessing each cell in that row.</p>