我正在尝试将 excel 文件读入 DataTable,但 IMEX 驱动程序不会读取列中的所有数据。这有什么问题?
OleDbConnection dCon = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=HDR=YES;Excel 12.0;IMEX=1");
这是代码。
OleDbConnection dCon = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
fileName + ";Extended Properties=HDR=YES;Excel 12.0;IMEX=1");
OleDbDataAdapter dAdp = new OleDbDataAdapter("SELECT * FROM [Sheet1$]", dCon);
dAdp.TableMappings.Add("tbl", "Table");
dAdp.Fill(dSet);
DataTable dT = dSet.Tables[0];
for (int i = 0; i < dT.Rows.Count; i++)
{
//code for getting the values.
}