EasyXLS

How to read Excel file in C# and VB.NET

EasyXLS™ library allows you to read data from Excel file. The data can be read from an Excel sheet or from the active Excel sheet. The entire sheet data or only data from ranges of cells can be read.

EasyXLS can be successfully used to also read large Excel files having big volume of data with fast reading time.

EasyXLS permits you to read Excel files without Excel installed, without Interop, without OLEDB or any other additional software installed.

The source code samples can be integrated in:
- ASP.NET web pages
- Windows applications
- Windows Forms (WinForms)
- Console applications
- Windows service applications
- ASP.NET MVC web applications

Source code sample

Step 1: Download and install EasyXLS Excel Library for .NET

To download the trial version of EasyXLS Excel Library, press the below button:

Download EasyXLS™ Excel Library for .NET

If you already own a license key, you may login and download EasyXLS from your account.

Step 2: Create a C# or VB.NET project

If don't have a project, create one as ASP.NET web application, windows forms app, console application, class library or service.

Step 3: Include EasyXLS library into project

EasyXLS.dll must be added as reference to your project. EasyXLS.dll can be found after installing EasyXLS, in "Dot NET version" folder.

Add EasyXLS reference

Step 4: Run C# or VB.NET code that reads Excel file

The below example shows how to read Excel file in C# and VB.NET.

C#.NET
VB.NET

Read Excel file having one sheet

Reading data from Excel file, if the Excel file has only one sheet, is the easiest approach. The Excel data can be read with one single line of code using:
- ExcelDocument.easy_ReadXLSXActiveSheet_AsDataSet method for XLSX file
- ExcelDocument.easy_ReadXLSBActiveSheet_AsDataSet method for XLSB file
- ExcelDocument.easy_ReadXLSActiveSheet_AsDataSet method for XLS file

The above code sample shows how to achieve this goal.

Read Excel file having multiple sheets

There are three approaches for reading data from an Excel file with multiple sheets.

I. Usually the first sheet is the active sheet inside an Excel file. If this is your case or if you are reading data from another active sheet use:
- ExcelDocument.easy_ReadXLSXActiveSheet_AsDataSet method for XLSX file
- ExcelDocument.easy_ReadXLSBActiveSheet_AsDataSet method for XLSB file
- ExcelDocument.easy_ReadXLSActiveSheet_AsDataSet method for XLS file

II. For reading data from an Excel sheet and the name of the sheet is known, EasyXLS recommends the use of:
- ExcelDocument.easy_ReadXLSXSheet_AsDataSet method for XLSX file
- ExcelDocument.easy_ReadXLSBSheet_AsDataSet method for XLSB file
- ExcelDocument.easy_ReadXLSSheet_AsDataSet method for XLS file

III. For reading data from an Excel sheet and the name of the sheet is not known, the first step is to find the sheet name using:
- ExcelDocument.easy_ReadXLSXFile_SheetNames method for XLSX file
- ExcelDocument.easy_ReadXLSBFile_SheetNames method for XLSB file
- ExcelDocument.easy_ReadXLSFile_SheetNames method for XLS file

Then, read the sheet data in DataSet using:
- ExcelDocument.easy_ReadXLSXSheet_AsDataSet method for XLSX file
- ExcelDocument.easy_ReadXLSBSheet_AsDataSet method for XLSB file
- ExcelDocument.easy_ReadXLSSheet_AsDataSet method for XLS file

Read range of Excel cells

EasyXLS enables you to read data from Excel file either from the entire sheet or from a range of cells. Reading only a range of cells is a very useful option especially for large Excel files because it reduces the speed of the reading process.

In order to read multiple cell ranges at once from Excel sheet, the range parameter must be passed to the method as union of ranges (multiple ranges separated by comma).

All the methods that allow reading Excel sheets have parameters that permit reading data only from ranges of cells.

Read XLSX, XLSB, XLSM and XLS files

This code sample shows how to read XLSX file. Similarly, you can read XLSM, XLSB, XLS files using:
- ExcelDocument.easy_ReadXLSXActiveSheet_AsDataSet or ExcelDocument.easy_ReadXLSXSheet_AsDataSet method for XLSX and XLSM files
- ExcelDocument.easy_ReadXLSBActiveSheet_AsDataSet or ExcelDocument.easy_ReadXLSBSheet_AsDataSet method for XLSB files
- ExcelDocument.easy_ReadXLSActiveSheet_AsDataSet or ExcelDocument.easy_ReadXLSSheet_AsDataSet method for XLS files

Read Excel file into DataTable

EasyXLS allows reading an Excel file into a DataTable. The DataTable can be used as data source of a GridView, DataGridView, DataGrid or for any other purposes.

Read Excel file into DataSet

EasyXLS allows reading an Excel file into a DataSet. The above code sample shows how to achive this goal. For more code samples see the below link.

Read Excel file and insert data into SQL database

EasyXLS allows reading an Excel file. The data from the Excel sheet can be inserted into SQL table.

Read password protected Excel file

EasyXLS allows reading encrypted Excel file. The Excel file can be password protected.

Getting started with EasyXLS Excel library

To download the trial version of EasyXLS Excel Library, press the below button:

Download EasyXLS™ Excel Library for .NET

If you already own a license key, you may login and download EasyXLS from your account.

After installation, you will need to create a C# or VB.NET project and add a reference to EasyXLS.dll.



Available for: Professional, Excel Reader
Go to top

EasyXLS Excel libraries:

.NET
.NET Excel Library
full .NET version to import, export or convert Excel files
.NET Excel Reader
.NET version to read and import Excel files
Download EasyXLS™ Excel Library for .NET

File formats:

Office 365
MS Excel 2021 - 2024
MS Excel 2007 - 2019
MS Excel 97 - 2003
XLSXXLSMXLSBXLS
XMLHTMLCSVTXT