asp.net怎么读取excel

来源:互联网 发布:生命游戏 java代码 编辑:程序博客网 时间:2024/06/06 15:52

asp.net怎么读取excel

DataTable Excel_UserInfo = new DataTable();
string strConn = @"Provider=Microsoft.ACE.OLEDB.12.0;" + "Data Source=" + fileInfo.FullName + ";" + "Extended Properties=/"Excel 12.0;HDR=YES;IMEX=1;/"";
string strExcel = "select * from [sheet1$]";

using (OleDbDataAdapter adaptor = new OleDbDataAdapter(strExcel, strConn))
{
DataSet ds = new DataSet();
adaptor.Fill(ds);
Excel_UserInfo = ds.Tables[0];
}

原创粉丝点击