EasyXLS

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

EasyXLS™ library allows you to import data from an Excel file or other sheet elements like cell formatting, charts, pivot tables, comments, images and others.

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

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

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

 Table of contents

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 imports data from Excel file

The below example shows how to import data from Excel file in C# and VB.NET. After that, best techniques about importing the entire Excel file structures or importing Excel data to DataTable, GridView, DataGridView, DataSet, DataGrid and List are shown.

1. Import data from Excel file

EasyXLS allows you to import data from an Excel sheet or from the active Excel sheet. The entire sheet data or only data from ranges of cells can be imported.

C#.NET
VB.NET

2. Import data from Excel file having one sheet

Importing data from an Excel file, if the Excel file has only one sheet, is the easiest approach. The Excel data can be imported 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.

3. Import data from Excel file having multiple sheets

There are three approaches for importing 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 importing 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 importing 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 importing 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, import 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

4. Import data from range of Excel cells

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

In order to import 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 importing Excel to DataSet have parameters that permit importing only ranges of cells.

5. Import all Excel file structures

EasyXLS allows you to import the whole Excel file with sheets, data inside sheets, formulas, cell formatting, comments, hyperlinks, images, data validation, page setup, macros, groups, filters, charts, pivot tables and pivot charts.

C#.NET
VB.NET

6. Import Excel file to SQL table in C# and VB.NET

EasyXLS library can be used to import Excel data to database like SQL Server, MySQL, Oracle, MS Access or any other database.

7. Import Excel file to DataTable in C# and VB.NET

EasyXLS library can be used to import Excel sheets into DataTable. The DataTable can be the used as data source of a GridView, DataGridView, DataGrid or for any other purposes.

8. Import Excel file to GridView in C# and VB.NET from ASP.NET

EasyXLS library can be used to import Excel data into GridView from ASP.NET web applications.

9. Import Excel file to DataGridView in C# and VB.NET

EasyXLS library can be used to import Excel data into DataGridView from windows applications and windows forms.

10. Import Excel file to DataSet in C# and VB.NET

EasyXLS library can be used to import Excel sheets into DataSet from windows applications, ASP.NET pages or console applications.

11. Import Excel file to list in C# and VB.NET

EasyXLS library can be used to import Excel sheets into lists of data.

12. Import Excel file to DataGrid in C# and VB.NET

EasyXLS library can be used to import Excel data into DataGrid from windows applications and windows forms.

13. Import Excel to XML in C# and VB.NET

EasyXLS library can be used to import Excel data into XML. The entire sheet data can be added to XML or only a range of cells.

14. Import data from XLSX file in C# and VB.NET

EasyXLS allows importing data from XLSX file from windows applications or ASP.NET pages. Similarly, as shown in the above code sample, you can import data from XLSX file using ExcelDocument.easy_ReadXLSXActiveSheet_AsDataSet, ExcelDocument.easy_ReadXLSXSheet_AsDataSet or ExcelDocument.easy_LoadXLSXFile methods.

15. Import data from XLS file in C# and VB.NET

EasyXLS allows importing data from XLS file from windows applications or ASP.NET pages. Similarly, as shown in the above code sample, you can import data from XLS file using ExcelDocument.easy_ReadXLSActiveSheet_AsDataSet, ExcelDocument.easy_ReadXLSSheet_AsDataSet or ExcelDocument.easy_LoadXLSFile methods.

16. Import data from XLSM file in C# and VB.NET

EasyXLS allows importing data from XLSM file from windows applications or ASP.NET pages. Similarly, as shown in the above code sample, you can import data from XLSM file using ExcelDocument.easy_ReadXLSXActiveSheet_AsDataSet, ExcelDocument.easy_ReadXLSXSheet_AsDataSet or ExcelDocument.easy_LoadXLSXFile methods.

17. Import data from XLSB file in C# and VB.NET

EasyXLS allows importing data from XLSB file from windows applications or ASP.NET pages. Similarly, as shown in the above code sample, you can import data from XLSB file using ExcelDocument.easy_ReadXLSBActiveSheet_AsDataSet, ExcelDocument.easy_ReadXLSBSheet_AsDataSet or ExcelDocument.easy_LoadXLSBFile methods.

18. Import password protected Excel file in C# and VB.NET

EasyXLS allows importing 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