if (flUpload.HasFile) { string path = Server.MapPath("~/Administrator/UploadedExcelFile/"); flUpload.SaveAs(path + flUpload.FileName); string path1 = Server.MapPath("~/Administrator/UploadedExcelFile/" + flUpload.FileName); OleDbConnection MyConnection = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source='" + path1 + "';Extended Properties=Excel 12.0;"); OleDbDataAdapter MyCommand = new System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection); DtSet = new System.Data.DataSet(); //Bind all excel data in to data set MyCommand.Fill(DtSet, "[Sheet1$]"); DataTable dt = new DataTable(); dt = DtSet.Tables[0]; MyConnection.Close(); //ViewState["myTable"] = dt; if (dt != null) { foreach (DataRow dr in dt.Rows) { } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)