Tuesday, 29 May 2012

Welcome

Reading Excel file in ASP NET MVC

[HttpPost]
   
   public ActionResult ImportLegacyCasesResult(HttpPostedFileBase file)
        {
            var data = (DataTable)null;
            OleDbConnection excelConnection = new OleDbConnection();
            try
            {
                DataSet ds = new DataSet();
                string strFilePath = string.Empty;

                //The process cannot access the file because it is being used
                GC.Collect();
                GC.WaitForPendingFinalizers();

                if (Request.Files["file"].ContentLength > 0)