凌寒飘香

____成风破浪会有时,直把云帆济沧海!

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: :: 管理 ::

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);

posted on 2013-02-07 15:04  凌寒飘香  阅读(195)  评论(0编辑  收藏  举报