hi frnds,
please explain me how t o view the excel sheet data in grid view in C#lang.
regards
chiranjeevi
How t o view the excel sheet data in grid view in C#lang.
1 Answer
Know the answer? Post it. Somebody with the same question will find it here.


Marimuthu ArigovindasamyRank #5,893 · 283 reputationPosted Jun 27, 2010, 7:56 PM EDT
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\\Muthu\\Tech\\Sample.xls" + ";" +
"Extended Properties=Excel 8.0;";
OleDbConnection oledbConn = new OleDbConnection(strConn);
oledbConn.Open();
OleDbCommand oledbCommand = new OleDbCommand("SELECT * FROM [Sheet1$]", oledbConn);
OleDbDataAdapter oledbDataAdapter = new OleDbDataAdapter();
oledbDataAdapter.SelectCommand = oledbCommand;
DataSet ds = new DataSet();
oledbDataAdapter.Fill(ds);
grd1.DataSource = ds.Tables[0].DefaultView;
grd1.DataBind();