简体   繁体   English

从 excel 导入错误 Microsoft.ACE.OLEDB.12.0 提供程序未在本地机器上注册

[英]Import from excel error Microsoft.ACE.OLEDB.12.0 provider is not registered on the local machine

i try to use ms interopt to import data from excel file, i have install Microsoft office 2007 in my computer and working fine, when i use the code in another computer have Microsoft office 2019 installed i face this error, i install我尝试使用 ms interopt 从 excel 文件中导入数据,我已经在我的计算机上安装了 Microsoft Office 2007 并且工作正常,当我在另一台计算机上使用代码时安装了 Microsoft Office 2019 我遇到了这个错误,我安装

Microsoft Access Database Engine 2010 Redistributable 

but not fix the problem , also i search fro link of 2007 System Driver Data Connectivity Component, but i cannot find any one, and Microsft has remove the file, this is my code:但没有解决问题,我也搜索了 2007 System Driver Data Connectivity Component 的链接,但我找不到任何一个,并且 Microsft 已删除该文件,这是我的代码:

using System.Data.OleDb;
   OleDbConnection conn=null;
            DataTable ExcelDataTables = null;
            try { 
            
                  
         conn = new OleDbConnection();
        conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + ExcelFilePath + ";Extended Properties=" + "\"Excel 12.0 Xml;HDR=YES;IMEX=1\"";
                   conn.Open();
                   ExcelDataTables = conn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
                   String[] ExcelSheetNames = new String[ExcelDataTables.Rows.Count];
        int i = 0;

                   // Add the sheet name to the string array.
                   foreach (DataRow row in ExcelDataTables.Rows)
                   {
                    ExcelSheetNames[i] = row["TABLE_NAME"].ToString();//.Replace("'","").Replace("$", "");
        i++;
                   }

    // Loop through all of the sheets if you want too...
    /*for (int j = 0; j < excelSheets.Length; j++)
    {
        // Query each excel sheet.
    }*/

    conn.Close();
                conn = null;
         LSTBox_ExcelSheetNames.DataSource = ExcelSheetNames;
            }
            catch (Exception ex)
            {
                if (conn != null)
                    conn.Close();
                conn = null;

                ExcelDataTables = null;
                FRM_MSG f = new FRM_MSG();
                f.ShowDLG(" ",
                ex.Message + "\n" + ex.StackTrace.ToString(),
                            FRM_MSG.MSGIcon.Error,
                            FRM_MSG.BTNS.One,
                            new string[] { "Ok" });
            }

please give me a link to 2007 System Driver Data Connectivity Component.请给我一个 2007 系统驱动程序数据连接组件的链接。

The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine. 'Microsoft.ACE.OLEDB.12.0' 提供程序未在本地计算机上注册。

The documentation states MS Access drivers (including the OLEDB driver) only work under the x86 platform and is incompatible under the x64 or AnyCPU platform.文档说明 MS Access 驱动程序(包括 OLEDB 驱动程序)在 x86 平台下工作,在 x64 或 AnyCPU 平台下不兼容。 However this appears to be untrue.然而,这似乎是不真实的。 Ref: https://stackoverflow.com/a/32760211/495455参考: https ://stackoverflow.com/a/32760211/495455

First download the Microsoft Access Database Engine 2010 Redistributable making sure you tick the _64.exe version: http://www.microsoft.com/en-us/download/details.aspx?id=13255首先下载 Microsoft Access Database Engine 2010 Redistributable,确保勾选 _64.exe版本: http ://www.microsoft.com/en-us/download/details.aspx?id=13255

  1. Extract the AccessDatabaseEngine_x64.exe to a folder to get the AceRedist.msi and Data.cab files.将 AccessDatabaseEngine_x64.exe 提取到一个文件夹以获取 AceRedist.msi 和 Data.cab 文件。
  2. Open command prompt in Admin mode在管理员模式下打开命令提示符
  3. cd to the folder you extracted the download and execute the MSI with the passive argument: cd 到您提取下载的文件夹并使用被动参数执行 MSI:

AceRedist.msi /passive

After these steps you should be able to run the application after building in x64 or AnyCPU build configuration.完成这些步骤后,您应该能够在 x64 或 AnyCPU 构建配置中运行应用程序。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:“ Microsoft.ACE.OLEDB.12.0”提供程序未在本地计算机上注册” - Error: 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine' Microsoft.ACE.OLEDB.12.0&#39;提供程序未在本地计算机上注册错误 - Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine error 未在本地计算机上注册“ Provider = Microsoft.ACE.OLEDB.12.0”提供程序 - The 'Provider=Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine microsoft.ace.oledb.12.0提供程序未在本地计算机上注册 - the microsoft.ace.oledb.12.0 provider is not registered on the local machine “&#39;Microsoft.ACE.OLEDB.12.0&#39; 提供程序未在本地计算机上注册” - "The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine" 'Microsoft.ACE.OLEDB.12.0' 提供程序未在本地计算机上注册 - The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine “Microsoft.ACE.OLEDB.12.0”提供程序未在本地计算机上注册。 - The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine. 'Microsoft.ACE.OLEDB.12.0' 提供程序未在本地计算机(服务器)上注册 - The 'Microsoft.ACE.OLEDB.12.0' provider is not registered on the local machine (server) Microsoft.ACE.OLEDB.12.0提供程序未在本地计算机上注册? - Microsoft.ACE.OLEDB.12.0 Provider is not registered on the Local Machine? microsoft.ace.oledb.12.0 provider未在本地注册 - microsoft.ace.oledb.12.0 provider is not registered on the local machine
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM