Import Excel Sheet Data in MS SQL server Database using AngularJS

Today in this article, I will explain how to Import Excel Sheet Data in MS SQL server Database using AngularJS

Here in this example, we will use the js-xlsx javascript library which is a Parser and writer for various spreadsheet formats.
Import excel data to Sql Server database using AngularJS
Sample Excel File

{{Message}}

First Name Last Name EmailID City Country
{{a.FirstName}} {{a.LastName}} {{a.EmailID}} {{a.City}} {{a.Country}}
Import Excel Sheet Data in MS SQL server Database using AngularJS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;

namespace ngImportExcelFile.Controllers
{
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            return View();
        }

        [HttpPost]
        public ActionResult SaveData(List<Employee> employees)
        {
            bool status = false;
            if (ModelState.IsValid)
            {
                using (MyDatabaseEntities dc = new MyDatabaseEntities())
                {
                    foreach (var i in employees)
                    {
                        dc.Employees.Add(i);
                    }
                    dc.SaveChanges();
                    status = true;
                } 
            }
            return new JsonResult { Data = new { status = status } };
        }
    }
}
Posted By :