DataSet ds = new DataSet(); OleDbCommand excelCommand = new OleDbCommand(); OleDbDataAdapter excelDataAdapter = new OleDbDataAdapter(); string excelConnStr; if (Extension != ".xlsx") { excelConnStr = String.Format("Provider=Microsoft.Jet.OleDb.4.0; Data Source = {0}; Extended Properties =\"Excel 8.0", filelocation); } else { excelConnStr = String.Format("Provider=Microsoft.ACE.OLEDB.12.0; Data Source = {0}; Extended Properties =\"Excel 12.0", filelocation); } OleDbConnection excelConn = new OleDbConnection(excelConnStr); excelConn.Open(); DataTable dt= new DataTable(); excelCommand = new OleDbCommand("SELECT * FROM [Sheet1$]", excelConn); excelDataAdapter.SelectCommand = excelCommand; excelDataAdapter.Fill(dt);
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)