Kalyani Shevale

Kalyani Shevale

  • NA
  • 3.2k
  • 659k

if Excel file uploading on Godadday Server that time Error

Aug 20 2019 12:02 AM
if Excel file is uploading that time THis Error Occured Please help me...
 I have attached Error please check and Suggest me.
 
below code is Excel File Uploading
  1. public ActionResult UploadExcel()  
  2.      {  
  3.          try  
  4.          {  
  5.   
  6.   
  7.              int intUploadedFiles = Request.Files.Count;  
  8.              var files = Request["File"];  
  9.              HttpPostedFileBase file = Request.Files[0];  
  10.              var fileName = Path.GetFileName(file.FileName);  
  11.   
  12.              if (file != null)  
  13.              {  
  14.   
  15.                  string strPath = "/ExcelFilePaySlipUploadMonthly/";  
  16.                  if (!System.IO.Directory.Exists(Server.MapPath(strPath)))  
  17.                  {  
  18.                      System.IO.Directory.CreateDirectory(Server.MapPath(strPath));  
  19.                  }  
  20.                  file = Request.Files[0];  
  21.                  fileName = Path.GetFileName(file.FileName);  
  22.   
  23.                  System.IO.DirectoryInfo dir = new System.IO.DirectoryInfo(Server.MapPath(strPath));  
  24.                  int count = dir.GetFiles().Length;  
  25.                  fileName = fileName.Substring(0, fileName.IndexOf('.')) + "_" + DateTime.Now.Millisecond + "-" + DateTime.Now.Second + "-" + DateTime.Now.Minute + "-" + DateTime.Now.Hour + "-" + DateTime.Now.Day + "-" + DateTime.Now.Month + "-" + DateTime.Now.Year + "." + fileName.Substring(fileName.IndexOf('.') + 1);  
  26.   
  27.                  var path = Path.Combine(Server.MapPath(strPath), fileName);  
  28.                  file.SaveAs(path);  
  29.   
  30.                  var excel = new ExcelQueryFactory(path);  
  31.   
  32.                  var punr = (from a in excel.Worksheet("PaySlip")  
  33.                              select a).Skip(1);  
  34.                  List lst = (from _data in punr  
  35.                                                                  select new ViewModel.Admin.PaySlip_SalaryData()  
  36.                                                                  {  
  37.   
  38.                                                                      Month = _data[1],  
  39.                                                                      Year = _data[2],  
  40.                                                                      Location = _data[3],  
  41.                                                                      Emp_Code = _data[4],  
  42.                                                                      Department = _data[5],  
  43.                                                                      Designation = _data[6],  
  44.                                                                      Name = _data[7],  
  45.                                                                      UAN_No = _data[8],  
  46.                                                                      ESIC_No = _data[9],  
  47.                                                                      Bank_Name = _data[10],  
  48.                                                                      Bank_Account_No = _data[11],  
  49.                                                                      Present_Days = _data[12],  
  50.                                                                      Absent_Days = _data[13],  
  51.                                                                      Basic =String.Format("{0:N}",Math.Round(Convert.ToDecimal(_data[14]))),  
  52.                                                                      HRA = String.Format("{0:N}", Math.Round(Convert.ToDecimal(_data[15]))),  
  53.                                                                      CONVEYANCE = String.Format("{0:N}", Math.Round(Convert.ToDecimal(_data[16]))),  
  54.                                                                      Special_Allowance = String.Format("{0:N}", Math.Round(Convert.ToDecimal(_data[17]))),  
  55.                                                                      Gross = String.Format("{0:N}", Math.Round(Convert.ToDecimal(_data[18]))),  
  56.                                                                      PF_Emp = String.Format("{0:N}", Math.Round(Convert.ToDecimal(_data[19]))),  
  57.                                                                      ESIC_Emp =  ( _data[20]),  
  58.                                                                      PT = _data[21],  
  59.                                                                      TDS = _data[23],  
  60.                                                                      Variable_Salary = _data[24],  
  61.                                                                      Salary_Advance = _data[25],  
  62.   
  63.                                                                      LWF = _data[26],  
  64.                                                                      Total_Deduction = String.Format("{0:N}", Math.Round(Convert.ToDecimal(_data[27]))),  
  65.                                                                      Net_salary = String.Format("{0:N}", Math.Round(Convert.ToDecimal(_data[28]))),  
  66.                                                                      PF_Comp = _data[29],  
  67.                                                                      ESIC_Comp =  _data[30],  
  68.                                                                      Total_CTC = String.Format("{0:N}", Math.Round(Convert.ToDecimal(_data[31]))),  
  69.                                                                      Leave_Balance_PL = _data[32],  
  70.                                                                      Leave_Balance_GL = _data[33],  
  71.                                                                      Other = String.Format("{0:N}", Math.Round(Convert.ToDecimal(_data[34])))  
  72.                                                                  }).ToList().FindAll(m => !string.IsNullOrEmpty(m.Emp_Code));  
  73.                  TempData["SalList"] = lst;  
  74.              }  
  75.              ViewModel.Admin.PaySlip_SalaryData d = new ViewModel.Admin.PaySlip_SalaryData();  
  76.              return PartialView("UploadExcel", d);  
  77.          }  
  78.          catch(IOException e)  
  79.          {  
  80.              return View();  
  81.          }  
  82.      }  
 
 

Attachment: Error.zip

Answers (5)