我想從Excel工作表中填充我的datagrid視圖。我在這裏得到的錯誤信息是,oledb異常是無人看管 - >The 'Microsoft.ACE.OLEDB.14.0' provider is not registered on the local machine.
我是uisng office 2012,我必須使用任何參考。Excel到datagridview Microsoft.ACE.OLEDB.14.0
我把anycpu
X86放在項目屬性裏。
有系統文件:
using System;
using System.Data;
using System.Drawing;
using System.Reflection;
using System.Collections.Generic;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel;
using System.Data.OleDb;
private void importXSLToolStripMenuItem_Click(object sender, EventArgs e)
{
OleDbConnection connect = new OleDbConnection();
connect.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\test\csharp.net-informations.xls;ExtendedProperties=""Excel 14.0;HDR=YES;""";
OleDbCommand command = new OleDbCommand("SELECT ID, TYPE, BeginBorder (mm),EndBorder (mm)," + "FROM [P2S2$]", connect);
DataSet ds = new DataSet();
OleDbDataAdapter adapter = new OleDbDataAdapter(command);
adapter.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}
'Microsoft.ACE.OLEDB.14.0'是Access數據庫驅動程序。我相信你將不得不補充說明。 – Pynner
@Pynner:我已經將它添加到參考中,但它仍然遇到同樣的問題。 – linguini