First of all we are declaring the ODBC namespace which we will use an Excel DNS;
using System.Data.Odbc;
then we will write these codes for connecting to a specific Excel file;
String strConn = @"Dsn=Excel Files;dbq=excel_file_path;defaultdir=excel_file_dir;driverid=1046;maxbuffersize=2048;pagetimeout=5"; OdbcConnection objConn = new OdbcConnection(strConn); objConn.Open(); OdbcDataAdapter adp = new OdbcDataAdapter("select * from [Sheet1$]", objConn); DataSet ds = new DataSet(); adp.Fill(ds); dataGridView1.DataSource = ds.Tables[0]; objConn.Close();
Thats all by using these codes you have got the datas you wanted to...
Cheers;)
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: