Excel “External table is not in the expected format.”

后端 未结 24 1583
执念已碎
执念已碎 2020-11-22 05:13

I\'m trying to read an Excel (xlsx) file using the code shown below. I get an \"External table is not in the expected format.\" error unless I have the file already open in

24条回答
  •  花落未央
    2020-11-22 05:38

    "External table is not in the expected format." typically occurs when trying to use an Excel 2007 file with a connection string that uses: Microsoft.Jet.OLEDB.4.0 and Extended Properties=Excel 8.0

    Using the following connection string seems to fix most problems.

    public static string path = @"C:\src\RedirectApplication\RedirectApplication\301s.xlsx";
    public static string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;";
    

提交回复
热议问题