c#读取excel

string file = @"E:\Tra.xls";
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + file + ";Extended Properties=Excel 8.0");

conn.Open();
Console.WriteLine("连接成功");
OleDbCommand comm = new OleDbCommand("Select * from [Sheet1$]", conn);
OleDbDataReader re = null;
re = comm.ExecuteReader();

while (re.Read())
{

 

}

conn.close();

posted @ 2015-11-02 15:36  成小伟  阅读(134)  评论(0编辑  收藏  举报