Reading Excel file in C# Console Application – C# Programming Example
C# Console General

Reading Excel file in C# Console Application

How to read excel file in c# console application. how to read data from excel sheet using c#.

You may also like

This example created for to read an excel file with C# Console Application.

Using the Excel namespace in C#, we can load or open an Excel file and read the cell sheets.

Berfore the creating codes, here is the examples screenshot


C# read Excel file

Step 1: We have to  references Excel namespace to the project.

Step 2: Given this the using alias of Excel.

Note: if you create windows form application you have to add “using” like this.  The same name is used for the form application.
Because you will see in following codes Application class for creating new Excel App. Same name is used for Windows Form Application too.

Form App fixes

using ExcelApp = Microsoft.Office.Interop.Excel;
ExcelApp.Application excelApp = new ExcelApp.Application();
ExcelApp.Workbook excelBook = excelApp.Workbooks.Open(@”E:\readExample.xlsx”);
ExcelApp._Worksheet excelSheet = excelBook.Sheets[1];
ExcelApp.Range excelRange = excelSheet.UsedRange;


Step 3: Creating COM object referances and checking Excel program is exists


Step 4: Creating book, pages and range  variables


Step 5: Calculating rows and cols.


Step 6: Reading step by step cols and rows.


Step 7: After reading, relase the excel project.


Here are the all codes:



Leave a Comment

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

%d bloggers like this: