Welcome to FoxLearn
In this tutorial, I'll show you how to open, read and import excel file to DataGridView in c# using the ExcelDataReader library
Open your form designer, then drag TextBox, Button, Label, Combobox and DataGridView from the visual studio toolbox to your winform
Next, We will design a simple UI that allows you to select the excel file
then load data from the excel file to DataGridView based on the sheet name you selected from the Comboxbox
Right-click on your project, then select Manage Nuget Packages
Next, You need to install the ExcelDataReader library to your project
This is a lightweight and fast library written in c# for reading Microsoft Excel files
Add the click event handler to the Browse button allows you to select the excel file, then open and read all sheet data
You can use the CreateReader method of the ExcelReaderFactory class to read the excel file
Data that you read from excel file will be returned as DataSet
Next, you need to read all table names in the DataSet, then add the table name to the Combobox
Finally, you need to specify the table name you want to retrieve the data, then bind the data to the DataGridView
Thank you for watching this video and don't forget to subscribe to my channel