ASP.NET中读取Excel文件数据
程序代码 程序代码
string strPath = @"E:/test.xls";
string mystring = "Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = '" + strPath + "';Extended Properties=Excel 8.0";
OleDbConnection cnnxls = new OleDbConnection(mystring);
OleDbDataAdapter myDa = new OleDbDataAdapter("select * from [Sheet1$]", cnnxls);
DataSet myDs = new DataSet();
myDa.Fill(myDs);
this.GridView2.DataSource = myDs.Tables[0];
this.GridView2.DataBind();