We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to load data from Excel file to DataGrid/DataGridView?

Syncfusion Essential XlsIO is a .NET Excel library used to create, read, and edit Excel documents. Using this library, you can load data from Excel file to DataGrid or DataGridView in C# and VB.NET.

 

Using XlsIO the Excel data can be loaded to DataGrid/DataGridView in the following ways.

 

 

Steps to load data from an Excel file to DataGrid control programmatically:

 

  1. Create a new Windows Forms application

 

Create a Windows Forms application in Visual Studio

 

  1. Install Syncfusion.XlsIO.WinForms NuGet package as reference to your .NET Framework applications from the NuGet.org.

 

Add XlsIO reference to the project

 

  1. Include the following namespaces for DataGrid and XlsIO usage.

 

 

 

  1. Add the DataGrid control in the Form1.cs.

 

 

 

  1. Add a new button to load data from Excel file to DataGrid.

 

 

 

  1. Use the following code snippet to load the Excel workbook.

 

 

 

  1. Export the Excel sheet data to a DataTable by using the ExportDataTable() method.

 

 

 

  1. Load the exported DataTable to DataGrid object by seting DataSource property.

 

 

 

  1. Use the following complete code to load the data in Excel file to the DataGrid using XlsIO.

 

 

 

A complete working example to load data from Excel file to DataGrid or DataGridView along with input file used can be downloaded from Load-Excel-file-to-DataGrid.zip

 

We recommend you to walkthrough the documentation for importing data from other grid controls, other data objects and exporting operations available with XlsIO for various data objects (DataTable, CLR Objects, etc..).

 

An online sample link to import/export the Excel data from/to the DataGrid control via CLR Objects can be found here.

 

Note:

Starting with v16.2.0.x, if you reference Syncfusion assemblies from trial setup or from the NuGet feed, include a license key in your projects. Refer to link to learn about generating and registering Syncfusion license key in your application to use the components without trail message.

Article ID: Published Date: Last Revised Date: Platform: Control:
9100 08/06/2018 10/15/2018 WinForms XlsIO
Did you find this information helpful?
Add Comment
You must log in to leave a comment

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon