OpenFileDialog op = new OpenFileDialog(); //tool to open the file op.Filter = "ALL Files |*.*|Excel Files |*.XLSX"; //select the type of file that want open it if (op.ShowDialog() == DialogResult.OK) //user chose the file and press ok { con = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + op.FileName + ";Extended Properties=Excel 12.0"); //path of file(excel),and specifec the connection da = new OleDbDataAdapter("Select * from[sheet1$]", con);//get the data dt = new DataTable(); da.Fill(dt);//save or put the data in data table this.dataGridView1.DataSource = dt;//show the table in grid view
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)