title: opening an excel protected sheet using c#
body: <p>I am trying to open an excel file using c# however visual studio is giving this OLEDB exception: "Could not decrypt file." When opening a non prtected excel file the code works fine.</p>
  
  <p>Hereunder is my code:</p>
  
  <pre><code>string conn = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + s + ";Extended Properties='Excel 8.0;HDR=YES'";
          OleDbConnection objConn = new OleDbConnection(conn);
          objConn.Open();
  
          OleDbCommand cmd = new OleDbCommand("Select * from [Sheet1$]", objConn);
          OleDbDataAdapter da = new OleDbDataAdapter(cmd);
          da.Fill(dt);
  </code></pre>
  
  <p>I found the following website which suggests a workaround for vb but I couldn't get it to work in C#. <a href="http://www.connectionstrings.com/Articles/Show/how-to-open-password-protected-excel-workbook" rel="nofollow" title="here">VBA excel</a></p>
  
  <p>Any help will be greatly appreciated.</p>