title: Value cannot be null. (Parameter 's') While trying to upload excel file to db
body: <p>I am attending to upload and save the excel values to the database. At the point of saving the values to db I got the error <code>Value cannot be null. (Parameter 's')</code> I am guessing the problem could be EF related but I still can't pinpoint what to do to fix it.</p>
  <p>If there is no empty column the excel, the excel will successfully upload and saved to db.  But how do I handle if some excel columns are empty?</p>
  <p>Some columns could me empty that is why I have to make some nullable.</p>
  <p>I don't know what I am doing wrong</p>
  <pre><code>ex.StackTrace:
  
    at System.ThrowHelper.ThrowArgumentNullException(ExceptionArgument argument)
     at System.Int64.Parse(String s)
     at LoanWarehouse.Controllers.AccountUploadController.&lt;SaveCustomerUpload&gt;d__14.MoveNext() in C:\Users\DELL\source....\Controllers\UploadController.cs:line 409
  
  </code></pre>
  <p>Here is the method that is extracting values and saving to db</p>
  <pre><code>   public async Task&lt;Response&gt; SaveCustomerUpload(int UploadId, ExcelWorksheet workSheet, int rowSize)
          {
              Response response = new Response();
              response.IsSuccessful = true;
  
              List&lt;Customer&gt; CustomerDatalist = new List&lt;Customer&gt;();
  
              //skip first row for column header
              for (int i = 2; i &lt;= rowSize; i++)
              {
                  try
                  {
  
                      CustomerDatalist.Add(new Customer
                      {
                          CustId = long.Parse(workSheet.Cells[i, 1].Value.ToString()),
                          FirstName_CompanyName = workSheet.Cells[i, 2].Value.ToString(),
                          MiddleName = workSheet.Cells[i, 3].Value.ToString(),
                          Gender = workSheet?.Cells[i, 4]?.Value?.ToString(),
                          FatherName = workSheet?.Cells[i, 5]?.Value?.ToString(),
                          MotherName = workSheet?.Cells[i, 6]?.Value?.ToString(),
                          DateOfBirth = null,
                          BVN = long.Parse(workSheet?.Cells[i, 8]?.Value?.ToString()),
                          EmailAddress = workSheet?.Cells[i, 9]?.Value?.ToString(),
                          OfficeNumber = workSheet?.Cells[i, 10]?.Value?.ToString(),
                          Nationality = workSheet?.Cells[i, 11]?.Value?.ToString(),
                          PlaceOfBirth = workSheet?.Cells[i, 12]?.Value?.ToString(),
                          MaritalStatus = workSheet?.Cells[i, 13]?.Value?.ToString(),
                          SpouseName = workSheet?.Cells[i, 14]?.Value?.ToString(),
                          TelephoneNo = workSheet?.Cells[i, 15]?.Value?.ToString(),
                          MobileNo = workSheet?.Cells[i, 16]?.Value?.ToString(),
                          Address = workSheet?.Cells[i, 17]?.Value?.ToString(),
                          OfficeEmailAddress = workSheet?.Cells[i, 18]?.Value?.ToString(),
                          FaxNumber = workSheet?.Cells[i, 19]?.Value?.ToString(),
                          WebsiteURL = workSheet?.Cells[i, 20]?.Value?.ToString(),
                          RelatedComapany = workSheet?.Cells[i, 21]?.Value?.ToString(),
                          LegalConstitution = workSheet?.Cells[i, 22]?.Value?.ToString(),
                          ShareHolder = workSheet?.Cells[i, 22]?.Value?.ToString(),
                      }
                      
                      );
                  }
                  catch (Exception ex)
                  {
                      response.Message = ex.ToString();
                      response.IsSuccessful = false;
                      logger.Error(ex);
                      break;
                  }
              }
  
              if (response.IsSuccessful)
              {
                  //save the details for this upload
                  await _context.Customer.AddRangeAsync(CustomerDatalist);
                  await _context.SaveChangesAsync();
              }
              else
              {
                  //reverse the initial AccountUpload and delete the details
                  var CustomerUpload = await _context.Customer.FindAsync(UploadId);
                  _context.Customer.Remove(CustomerUpload);
                  await _context.SaveChangesAsync();
              }
  
  
              return response;
          }
  
  </code></pre>