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

后端 未结 24 1541
执念已碎
执念已碎 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:16

    I recently saw this error in a context that didn't match any of the previously listed answers. It turned out to be a conflict with AutoVer. Workaround: temporarily disable AutoVer.

    0 讨论(0)
  • 2020-11-22 05:18

    This can also be a file that contains images or charts, see this: http://kb.tableausoftware.com/articles/knowledgebase/resolving-error-external-table-is-not-in-expected-format

    The recommendation is to save as Excel 2003

    0 讨论(0)
  • 2020-11-22 05:19

    I had this problem and changing Extended Properties to HTML Import fixed it as per this post by Marcus Miris:

    strCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & importedFilePathAndName _
             & ";Extended Properties=""HTML Import;HDR=No;IMEX=1"";"
    
    0 讨论(0)
  • 2020-11-22 05:20

    Thanks for this code :) I really appreciate it. Works for me.

    public static string connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;";
    

    So if you have diff version of Excel file, get the file name, if its extension is .xlsx, use this:

    Private Const connstring As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + path + ";Extended Properties=Excel 12.0;";
    

    and if it is .xls, use:

    Private Const connstring As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" + path + ";Extended Properties=""Excel 8.0;HDR=YES;"""
    
    0 讨论(0)
  • 2020-11-22 05:20

    I have also seen this error when trying to use complex INDIRECT() formulas on the sheet that is being imported. I noticed this because this was the only difference between two workbooks where one was importing and the other wasn't. Both were 2007+ .XLSX files, and the 12.0 engine was installed.

    I confirmed this was the issue by:

    • Making a copy of the file (still had the issue, so it wasn't some save-as difference)
    • Selecting all cells in the sheet with the Indirect formulas
    • Pasting as Values only

    and the error disappeared.

    0 讨论(0)
  • 2020-11-22 05:21

    (I have too low reputation to comment, but this is comment on JoshCaba's entry, using the Ace-engine instead of Jet for Excel 2007)

    If you don't have Ace installed/registered on your machine, you can get it at: https://www.microsoft.com/en-US/download/details.aspx?id=13255

    It applies for Excel 2010 as well.

    0 讨论(0)
提交回复
热议问题