External table is not in the expected format.

前端 未结 1 953
无人共我
无人共我 2021-01-19 17:48

I am creating a small application to import excel data into my database, when i click the button it crashes with the error

External table is not in

1条回答
  •  被撕碎了的回忆
    2021-01-19 18:01

    Assuming you have done all the preparations including installing Microsoft Access 2010 Runtime to acquire the relevant drivers try the following as I had success with it in the past.

    If your input file is of a type *.xlsx trying replacing

    Extended Properties="Excel 12.0"
    

    in your connection string with

    Extended Properties="Excel 12.0 Xml"
    

    This issue normally happens with the problematic or mismatching format of Excel file so as a rule of thumb the first thing you would want to try is to open Excel and create a new .xlsx file with couple of sample data in it which you typed yourself (rather than copy/paste). You don't need much typing to test your code snippet. Couple of cells with the right info you're expecting will do. This approach eliminates having any problems with the actual Excel file rather than your C# code.

    Let us know how you went.

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