Click here to Skip to main content
16,021,293 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Insert Datas in Microsoft Excel to DataGridView in Windows Application Using c#
Posted
Updated 29-Dec-11 22:20pm
v2
Comments
sunil from madras 30-Dec-11 4:23am    
How to Insert Datas in Microsoft Excel to DataGridView in Windows Application Using c#
pls help me sir...........

Look it

string connstr ="Provider=Microsoft.Jet.Oledb.4.0;Data Source=C:\aaa.xls;Extended Properties=Excel 8.0"/>
        OleDbConnection conn = new OleDbConnection(connstr);
        string strSQL = "SELECT * FROM [Sheet$]";
 
        OleDbCommand cmd = new OleDbCommand(strSQL, conn);
        DataSet ds = new DataSet();
        OleDbDataAdapter da = new OleDbDataAdapter(cmd);
        da.Fill(ds);
        GridView1.DataSource = ds;
        GridView1.DataBind();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900