我在 youtube 上找到了一个视频,展示了如何将 excel 文件导入 datagridview。我收到一个错误:找不到可安装的 ISAM。
这是我的代码,我做错了什么?
private void button1_Click(object sender, EventArgs e)
{
OleDbConnection conn = new OleDbConnection();
conn.ConnectionString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Nick\Desktop\Pricing2.xlsx" + @";Exended Properties=""Excel 8.0;HDR=No;IMEX=1;ImportMixedTypes=Text;TypeGuessRows=0""";
OleDbCommand command = new OleDbCommand
(
"SELECT PartNumber,ShortDescription,RetailPrice,JobberPrice,BasePrice,YourDiscount,YourPrice,LongDescription FROM [Pricing$]",conn
);
DataSet ds = new DataSet();
OleDbDataAdapter adapter = new OleDbDataAdapter(command);
adapter.Fill(ds);
dataGridView1.DataSource = ds.Tables[0];
}