我正在尝试读取excel文件并将文件内容转换为数据表,但我不断收到此异常IErrorInfo.GetDescription失败,E_FAIL(0x80004005)指向特定行POCCommand.Fill(dt);
这就是我到目前为止尝试过我能做错什么?
string POCpath = @"p.xlsx";
string POCConnection = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + POCpath + ";Extended Properties=\"Excel 12.0;HDR=Yes;IMEX=1\";";
OleDbConnection POCcon = new OleDbConnection(POCConnection);
OleDbCommand POCcommand = new OleDbCommand();
DataTable dt = new DataTable();
OleDbDataAdapter POCCommand = new OleDbDataAdapter("select * from [Sheet1$] ", POCcon);
POCCommand.Fill(dt);
Console.WriteLine(dt.Rows.Count);