Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

exceldatareader example c#

1
private void btnBrowse_Click(object sender, EventArgs e)
        {
            this.openFileDialog1.Filter = "Excel Files(.xlsx)|*.xlsx";
            this.openFileDialog1.Title = "Select an excel file";
            if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                this.txtPath.Text = openFileDialog1.FileName;
                FileStream stream = File.Open(openFileDialog1.FileName, FileMode.Open, FileAccess.Read);
                IExcelDataReader excelReader = ExcelReaderFactory.CreateOpenXmlReader(stream);
                DataSet result = excelReader.AsDataSet();
 
                var people = new List<Person>();
                while (excelReader.Read())
                {
                    people.Add(new Person
                    {
                        FirstName = excelReader.GetString(0),
                        LastName = excelReader.GetString(1)
                    });
                }
 
                this.resultGrid.DataSource = people;
            }
        }
Comment

PREVIOUS NEXT
Code Example
Csharp :: minimize maximize restore wpf buttons 
Csharp :: else if c# 
Csharp :: how to write a list to csv c# 
Csharp :: an existing connection was forcibly closed by the remote host. .net core 
Csharp :: how to show an arrya in c# 
Csharp :: how to convert object in string JSON c# 
Csharp :: what is reflection in programming 
Csharp :: c# get type of class 
Csharp :: convert decimal to 2 decimal places c# 
Csharp :: subtract days c# 
Csharp :: unity c# change animation 
Csharp :: c# combobox add item 
Csharp :: c# picturebox transparente 
Csharp :: c# add time to datetime 
Csharp :: c# handle dbnull value 
Csharp :: unity banner Ad position 
Csharp :: c# create excel file 
Csharp :: mvc session key exists 
Csharp :: data annotations in asp.net core 
Csharp :: wpf clear grid 
Csharp :: how to use yield in c# 
Csharp :: entity framework delete record with foreign key constraint 
Csharp :: c# remove all items from list where item value is null 
Csharp :: how to generate a random number in c# 
Csharp :: remove last instance of string c# 
Csharp :: how to display array in string in c# 
Csharp :: unity initialize array 
Csharp :: delete all rows from table linq 
Csharp :: How to search values in the registry 
Csharp :: c sharp list 
ADD CONTENT
Topic
Content
Source link
Name
8+5 =