title: Reading multiple Excel worksheets inside a single xlsx using c#
body: <p>Using c# I can successfully open an excel document and read the data in the first worksheet with the code below. However, my .xlsx  has multiple worksheets so I would like to loop through the worksheet collection rather than hard coding the name of each worksheet. Many thanks.</p>
  
  <pre><code>       string path = @"C:\Extract\Extract.xlsx";
         string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;";
  
         string sql = "SELECT * FROM [Sheet1$]";
  
         using (OleDbDataAdapter adaptor = new OleDbDataAdapter(sql, connStr))
         {
             DataSet ds = new DataSet();
             adaptor.Fill(ds);
  
             DataTable dt = ds.Tables[0];
         }
  </code></pre>