public DataTable ExcelToDataTable(string filename)
{
DataTable dt=new DataTable();
string strCon = "Provider=Microsoft.Jet.OLEDB.4.0;Extended Properties=Excel 8.0;data source=" + filename;
OleDbConnection myConn = new OleDbConnection(strCon);
string strCom = " SELECT * FROM [Sheet1$]";
myConn.Open();
OleDbDataAdapter myCommand = new OleDbDataAdapter(strCom, myConn);
myCommand.Fill(dt);
myConn.Close();
return dt;
}
C#读取Excel
最新推荐文章于 2024-09-10 07:36:22 发布