private void button1_Click(object sender, EventArgs e) { string fileName = "C:\test.xlsx"; string connectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + fileName + ";Extended Properties=\"Excel 8.0;HDR=YES;\""; OleDbConnection con = new System.Data.OleDb.OleDbConnection(connectionString); con.Open(); OleDbDataAdapter cmd = new System.Data.OleDb.OleDbDataAdapter("select * from [SHEET1$]", con); DataSet excelDataSet = new DataSet(); cmd.Fill(excelDataSet); xl.DataSource = excelDataSet.Tables[0]; con.Close(); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)