create a new c# window application. then, add a datagrid to the form. then do this.
using System.Data.Odbc;
//add code after InitializeComponent();
OdbcConnection con = new OdbcConnection(@"Driver={Microsoft Excel Driver (*.xls)};DBQ=filename.xls");
OdbcCommand cmd = new OdbcCommand(@"SELECT * FROM [Sheet1$]");
cmd.Connection = con;
OdbcDataAdapter da = new OdbcDataAdapter(cmd);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
da.Fill(dt);
dataGridView1.DataSource = dt;
没有评论:
发表评论