private DataSet GetExcelData(string str)
{
str = @"D:/1/1.xlsx";
string strCon = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + str + ";Extended Properties=/"Excel 12.0;HDR=YES/"";
OleDbConnection myConn = new OleDbConnection(strCon);
string strCom = " SELECT * FROM [Sheet1$]";
myConn.Open();
OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom, myConn);
DataSet myDataSet = new DataSet();
myCommand.Fill(myDataSet, "[Sheet1$]");
myConn.Close();
return myDataSet;
}
读取excel数据的函数
最新推荐文章于 2022-06-21 22:35:33 发布