Copy Data From Excel to GridView

Labels:

We have to create a excel as a database.

Step 1 : Open Excel sheet and enter data's

Step 2 : Select the data's which u want.

Step 3 : Click Insert tab->Name->Define




Step 4 : Give the name for the selected data's




pgeExcel.cs

Now we display the excel database in a gridview which we created.

OleDbDataAdapter da;
OleDbConnection con = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;
data source=f:/Book1.xls;Extended Properties=Excel 8.0;");
con.open();
da = new OleDbDataAdapter("select * from emp", con);//emp is the name given in excel sheet
DataSet ds=new DataSet();
da.Fill(ds,"emp");
GridView1.DataSource=ds;
GridView1.DataBind();

0 comments:

Post a Comment