hi frnds,
please explain me how t o view the excel sheet data in grid view in C#lang.
regards
chiranjeevi
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Marimuthu ArigovindasamyPosted Jun 27, 2010, 11:56 PM
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();