Loading data from excel and display them with Paged List MVC

Today’s post will be different because it will be in English language. I’ll write a simple application MVC with data import from excel and displey them on the page(View) with “Paged List MVC”.

OK, so let’s try it.

Loading data from excel

In a first step is to create model:

Our example will be a table with question and answer which are stored in excel.

Next we will install EPPlus libery which can manage excel data.


Let’s create path file to our excel data. This is my example path so your could be different.

So I read the data from excel with the help of our EPPlus libery.

Variable woorkbook – mean our excel file, current – mean page worksheet which we want to load. Rest should be clear.

So let’s create list of our excel data to pass it to our table(View).

We are using simple loop to add our data to our list of “Example”. Now we can return our model.

View code:



Yay. Awesome, we get it.

But what if our list will have a lot of records. It doesn’t look very nice. Maybe we should paged it.

So let’s install PagedList library.


Implementation is so simple. Let’s add two parametrs to our Index

PageNumber is number page to be displayed, pageSize is how many intems u want to show on one single page.

OK it’s clear, next transform our List<Example> to PagedList<Example>.

And change code in View.



And add it at the end:

As a result, we will be able to switch pages.

It’s look like that:

pagedList MVC


This was my first post in english so don’t blame me so much. 🙂

After the implementation of pagedlist page looks more professional. Of course we can add Ajax to our application to switch between pages without reloading web page. But i think the post will be to long.

Link GitHub to current application.

Have a nice day 😉

Leave a Reply

Your email address will not be published. Required fields are marked *