62,074
社区成员
发帖
与我相关
我的任务
分享
public void UploadInventoryData(string sheetName, string excelFile)
{
string strConn = "Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + excelFile + ";" + "Extended Properties=Excel 12.0;";
string strExcel = "select * from [" + sheetName + "$]";
DataSet ds = new DataSet();
OleDbConnection conns = new OleDbConnection(strConn);
conns.Open();
OleDbDataAdapter adapter = new OleDbDataAdapter(strExcel, conns);
adapter.Fill(ds, "res");
conns.Close();
}