title: Looping through sheets
body: <p>I'm trying to use EPPlus to loop through an Excel workbook's sheets, but I'm not having any luck figuring out the syntax.</p>
  
  <p>I'm using C# right now.  I was able to get it working in VB.NET, but not C#.</p>
  
  <p>This is what I have that is <em>not</em> working in C#:</p>
  
  <pre><code>object Workbook01 = new OfficeOpenXml.ExcelPackage(WorkbookFilePath).Workbook;
  
  foreach (object sheet01 in Workbook01.Worksheets){
  
      // Code here.
  
  }
  </code></pre>
  
  <p>This gives an error that says:</p>
  
  <blockquote>
    <p>'object' does not contain a definition for 'Worksheets' and no extension method 'Worksheets' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)</p>
  </blockquote>
  
  <p>This is what I have in VB.NET that works fine:</p>
  
  <pre><code>Dim Wkbk As Object
  Wkbk = New OfficeOpenXml.ExcelPackage(wkbkFilePath).Workbook
  
  For Each sheet01 In Wkbk.Worksheets
  
      ' Code here
  
  Next sheet01
  </code></pre>
  
  <p>Maybe it's a mistake to compare C# to VB.NET for this project, but, either way, I need to figure out how to loop through all sheets with EPPlus in C#.</p>