using System.Data.OleDb;
string path = MapPath("~/Excel/" + Guid.NewGuid().ToString() + ".xls");
FileUpload1.PostedFile.SaveAs(path);
string strCon = " Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source = " + path + ";Extended Properties=Excel 8.0";
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();
DataTable dtUsers = myDataSet.Tables[0];
GridView1.DataSource = dtUsers;
GridView1.DataBind();