0
我在YouTube上找到了一個視頻,演示瞭如何將excel文件導入到datagridview。我收到錯誤:無法找到可安裝的ISAM。導入excel文件錯誤
這是我的代碼,我做錯了什麼?
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];
}
你是上帝,謝謝。 – 2010-12-16 08:28:29