In this article, you will learn how to create, read, and edit Excel spreadsheets in an ASP.NET MVC application. For this, we will create a spreadsheet application consisting of a feature-rich grid control to display and edit Excel files, as shown below.
- .NET API to Create ASP.NET Spreadsheet Application
- Steps to Create ASP.NET Spreadsheet Application
- Download Source Code
.NET API to Create ASP.NET MVC Spreadsheet Application
In order to create the spreadsheet application in ASP.NET MVC, we will use Aspose.Cells.GridJs. The API allows you to create web-based applications to display or edit spreadsheet documents quickly and easily. Furthermore, you can import the popular spreadsheet (XLS, XLSX, XLSM, XLSB, CSV, SpreadsheetML, ODS) file formats (read more). In addition, It provides a strong and rich Formula Calculation Engine to calculate not only the built-in functions but also custom formulas. You can install Aspose.Cells.GridJs from NuGet.
PM> Install-Package Aspose.Cells.GridJs
Steps to Create ASP.NET MVC Spreadsheet Application
The following are the steps to create a web-based spreadsheet application in ASP.NET MVC.
- Create a new ASP.NET Core Web App (Model-View-Controller) in Visual Studio.
2. Install Aspose.Cells.GridJs from NuGet.
3. Insert the following code into HomeController.cs.
4. Create a new class named TestConfig.cs in Models folder and add the following code (change the folder paths according to your environment).
5. Create a new class named LocalFileCache.cs in Models folder and add the following code.
6. Create a new controller named GridJs2Controller.cs and add the following code.
7. Insert the following code in the Configure function of Startup.cs and set the license file’s path (get a license for free).
8. Insert the following code in Views/Home/index.cshtml.
9. Create a new view named list.cshtml under Views/Home/ folder and insert the following code.
10. Download the xspread folder from GitHub and place it under wwwroot folder, as shown below.
11. Make sure that the port number specified in wwwroot/xspread/index.html is the same as the project’s port number.
12. Build the application and run it in your favorite browser.
Demo – Create or Edit Excel Files in ASP.NET MVC
The following is the demonstration of the ASP.NET MVC spreadsheet application we have just created.
Download Source Code
You can download the complete source code of the spreadsheet application from GitHub.
Get a Free License
You can use Aspose.Cells.GridJs without evaluation limitations using a temporary license.
In this article, you have learned how to create an ASP.NET MVC spreadsheet application with a range of features to create and edit Excel and other spreadsheet files. You can customize this application or integrate it into your own web application. In case you would have any queries, feel free to post to our forum.