Windows Form

Reading Excel file in C# Windows Form Application

Excel files are widely used by people all over the world for various tasks related to organization, analysis, and storage of tabular data. Since excel files are so common, we sometimes need to read data from an excel file or generate a report in excel format

In this article, I’ll show you how to read excel files step by step  in C# Windows Form using a very simple example. And you will find all of the code in bottom of article

C# read Excel file in Windows Form

 

Step 1:  Add a reference by right clicking to the “References”  in the Solution Explorer.  

 

Step 2: Then we will see the Reference Manager in the panel. We have to add the  Microsoft Excel XX.XX Object Library into our project as a reference for exporting to the Excel.

 

Step 3: After the adding is finished, let’s start the project. Add the namespace to using

 

Step 4: Then design the form as following

 

Step 6: Double click to button1 and add following codes.(Button1_Click event). Don’t forget changing excel file path( line 10 I saved in drive E as E:\readExample.xlsx)

 

After finished it will shown as following

 

All codes:

 

 

 

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.