protected void Upload_Click(object sender, EventArgs e) { try { strFileName = fleupForQuotation.PostedFile.FileName; if (strFileName.Trim() != "") { string folderpath = "F://Upload//"; string attachedFile = fleupForQuotation.PostedFile.FileName; if (Request.Browser.Browser == "IE") { fleupForQuotation.SaveAs(folderpath + fleupForQuotation.FileName); strFileName = folderpath + fleupForQuotation.FileName; } else { fleupForQuotation.SaveAs(folderpath + attachedFile); strFileName = folderpath + attachedFile; } hdnFileName.Value = strFileName; } else { } } catch (Exception ex) { SRCMError.ErrorLog(ex.ToString()); SRCMError.ExceptionToEventLog(ex); } string ConnectionString = "provider=Microsoft.Jet.OLEDB.4.0;" + @"data source=" + strFileName + ";" + "Extended Properties=Excel 8.0;"; OleDbConnection conn = new OleDbConnection(ConnectionString); conn.Open(); try { OleDbDataAdapter oda = new OleDbDataAdapter("select * from [Sheet1$]", conn); DataSet ds = new DataSet(); oda.Fill(ds, "Details"); grdExceltoGrid.DataSource = ds; grdExceltoGrid.DataBind(); } catch (Exception ex) { Response.Write(ex.Message); } finally { conn.Close(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)