Export excel to data table in c# using OleDbConnection
DataTable dt = new DataTable();
string strpath = "C:\\SheetFinal.xlsx";
String connstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strpath + ";Extended Properties=Excel 12.0;";
OleDbConnection con = new OleDbConnection(connstring);
OleDbDataAdapter da = new OleDbDataAdapter("select * from [Sheet1$]", con);
da.Fill(dt);
DataTable dt = new DataTable();
string strpath = "C:\\SheetFinal.xlsx";
String connstring = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + strpath + ";Extended Properties=Excel 12.0;";
OleDbConnection con = new OleDbConnection(connstring);
OleDbDataAdapter da = new OleDbDataAdapter("select * from [Sheet1$]", con);
da.Fill(dt);
No comments:
Post a Comment