( NAME = N'Students_log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS2\MSSQL\DATA\Students_log.ldf', SIZE = 1024KB, MAXSIZE = 2048GB, FILEGROWTH = 10%)ĪLTER DATABASE SET COMPATIBILITY_LEVEL = 110 ( NAME = N'Students', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL11.SQLEXPRESS2\MSSQL\DATA\Students.mdf', SIZE = 3072KB, MAXSIZE = UNLIMITED, FILEGROWTH = 1024KB ) You can create database with dummy database with Demo table and Data using the below scripts (using SQL server 2012 or above) USE Step 3: Now we need to connect our project with database, so get your database from SQL server and connect it with your MVC project, here I am using my local database "Students", with table "Student_details" here is the snapshot of database, with its current dummy data Step 2: Now you have generated basic MVC file template, now Right-click on your project(In Solution Explorer pane) ->Manage Nuget packages->In "Nuget package manager window" select the "Browse" tab, then search for "EPPlus", Select and click install.ĮPPlus is open source library, It writes Excel 2007/2010 files using the Open Office Xml format (xlsx) only. Select MVC template to generate basic HomeController and other details. Step 1: Create a project in your Visual Studio(2017 in my example), by opening Visual Studio and clicking "File"-> "New"-> "Project". So, we will be discussing other methods(using EPPlus and NPOI) to export data to excel file using MVC, let's start with method to export excel file using EPPlus. Many times, there can be a need of exporting your HTML table into excel (.xlsx) file while creating ASP.NET MVC application, and there are multiple ways for exporting to excel in C# MVC, one of the most common methods is to use Excel PIA (primary interop assemblies) but it is not recommended method as you would have to install Microsoft Office suite on your web server when you deploy your application on server, so it is not a good approach.