Reading from Excel: Microsoft.Jet.OLEDB.4.0 error on 64 bit systems

前端 未结 4 1622
醉酒成梦
醉酒成梦 2021-02-09 17:11

I am reading the contents of an excel sheet in my application using:

 OleDbConnection con = new OleDbConnection(\"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\"         


        
4条回答
  •  难免孤独
    2021-02-09 17:47

    Microsoft released a driver distribution with a 64-bit driver that works for Access and Excel. You can download both the 64-bit and 32-bit versions from the MS downloads site. The download page also has a brief outline of what you would need to change in your connection string to reference the ACE driver.

    In a nutshell, you install the 64-bit driver distribution and then change your connection string to something along the lines of:

    string connStr = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=""Excel 8.0;IMEX=1""";
    

提交回复
热议问题