您的位置:首页 > 其它

[收藏].Net如何读取Excel文件中的内容

2006-11-06 12:38 555 查看
读取Excel文件内容:

string StrConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + FilePath + ";" + "Extended Properties=Excel 8.0;";
OleDbConnection MyConn = new OleDbConnection(StrConn);
// MyConn.Open();
string StrExcel = "";
OleDbDataAdapter MyCommand = null;
DataSet ds = null;
StrExcel = "select * from [sheet1$]";
MyCommand = new OleDbDataAdapter(StrExcel, StrConn);
ds = new DataSet();
MyCommand.Fill(ds, "table1");
//MyConn.Close();
return ds.Tables["table1"];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: