using System.Data.OleDb;
using System.Data;
string strOdbcCon = @"Provider=Microsoft.Jet.OLEDB.4.0; Persist Security Info=False;Data Source=c://test.xls; Extended Properties=Excel 8.0";
//定义OleDbConnection对象实例并连接Excel表格
OleDbConnection OleDB = new OleDbConnection(strOdbcCon);
//定义OleDbDataAdapter对象实例并调用Select查询语句提取Excel数据信息
OleDbDataAdapter OleDat = new OleDbDataAdapter("select * from [登记表$]", OleDB);
//OleDbDataAdapter OleDat = new OleDbDataAdapter("select * from [sheet2$]", OleDB);
//OleDbDataAdapter OleDat = new OleDbDataAdapter("select * from [sheet3$]", OleDB);
DataTable dt = new DataTable();
//定义DataTable对象实例
OleDat.Fill(dt);