C# ASP.NET Excel Viewer

Do you want to display Microsoft Excel worksheets within your web application? Are you looking for an ASP.NET MVC Excel Viewer? If yes, you have landed in an absolutely correct place. In this blog, you will learn how to create an Excel Viewer and display Excel worksheets in ASP.NET MVC applications using C#. After spending a few minutes and following some simple steps you will have your own Excel (XLS or XLSX) Viewer up and running. So let’s begin.

Features of ASP.NET MVC Excel Viewer

Our ASP.NET Excel Viewer will have the following features and you can enhance them as per your requirements.

  1. Browse and view Excel files.
  2. Load default Excel file on page load.
  3. Tabs to navigate between Excel worksheets.

Steps to Create Excel Viewer in ASP.NET MVC

The following are some easy steps to view Excel files in ASP.NET MVC.

1. Create a new ASP.NET MVC web application in Visual Studio.

ASP.NET MVC Web Application

2. Open NuGet Package Manager and install Aspose.Cells for .NET package.

View Excel files in ASP.NET in browser

3. Create a new folder “Documents” to keep the Excel files and a subfolder “Rendered” to save rendered images.

4. Create a new folder with the name “Helpers” in the root folder.

5. Create a new class with the name “Sheet” in the “Helpers” folder to store the Excel worksheets’ information.

6. Open the “HomeController” class and replace it’s code with the following. Make sure to replace the default Excel file’s name in Index action.

7. Open Views/Home/index.cshtml and replace its content with the following script.

8. Build the application and run it in your favorite browser.

View Excel Files in ASP.NET MVC Viewer - Demo

The default Excel file will be displayed when you’ll start the application for the first time.

Excel Viewer in ASP.NET C#

Open an Excel File

In order to open an Excel file, click the browse button and select the file from the list.

Browse Excel Files
Open Excel file in ASP.NET C#

All the worksheets in the Excel workbook will be displayed in the form of tabs. You can click the tabs to navigate between worksheets.

Display Excel Files in ASP.NET

Download Source Code

This application is open source and its source code is available on GitHub.

Get a Temporary License for Aspose.Cells for .NET

You can get the temporary license of Aspose.Cells for .NET API to avoid evaluation/trial limitations.