External table is not in the expected format thrown only in certain situations
<p>I am trying to open an xlsx file and I get the External table is not in the expected format only when I open from a certain area of my app. So it works just fine if I call it from 1 area, but then I do the same thing from a different part of the app, calling the same code block, and it throws that exception. Same code block. Same excel file.</p>

<pre><code>string connectionString = "Provider="+ GetProvider(fileName) +"; data source=" + fileName + "; " + GetExtendedProperties(fileName);

                using (var connection = new OleDbConnection(connectionString))
                {
                    connection.Open();

                    using (DataTable schemaTable = connection.GetOleDbSchemaTable(OleDbSchemaGuid.Tables,
                                                                                  new object[] { null, null, null, "TABLE" }))
                    {
                        if (schemaTable != null &amp;&amp; schemaTable.Rows != null)
                        {
                            List&lt;string&gt; validTables = schemaTable.Rows.OfType&lt;DataRow&gt;().Select(row =&gt; (string)row["TABLE_NAME"]).ToList();

                            validTables.ForEach(table =&gt;
                            {
                                if (table.Contains('$'))
                                {
                                    results.WorkSheets.Add(table.Trim('\'', '$'));
                                }
                                else
                                {
                                    results.NamedRanges.Add(table);
                                }
                            });
                        }
                    }
                }
</code></pre>

<p>My connection string:</p>

<p>Provider=Microsoft.ACE.OLEDB.12.0; data source=C:\moses\BLANKTest\Table.xlsx; Extended Properties="Excel 12.0 Xml";</p>

<p>Also tried the connection string taking out the "Xml" at the end. No luck.</p>

<p>Not sure what is going on here.</p>
