日期:2014-05-17 浏览次数:20825 次
protected void Button1_Click(object sender, EventArgs e) { strPath = Server.MapPath(@"~/updata/" + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls"); File1.PostedFile.SaveAs(strPath); 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); GridView2.DataSource = myDs.Tables[0]; GridView2.DataBind(); }