【发布时间】:2017-02-27 15:31:26
【问题描述】:
我正在尝试读取 excel 文件并将文件的内容转换为数据表,但我不断收到此异常 IErrorInfo.GetDescription failed with 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);
【问题讨论】: