摘要:asp.net 滙入excel
xlsPath = "/images/man.xls";
sheetName = "工作表1";
string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + xlsPath
+ ";Extended Properties='Excel 8.0;IMEX=1;'";
//語法就是大家都知道的SQL語法啦
string strComm = "SELECT id,name FROM [" + sheetName + "$]";
OleDbConnection dataConn = new OleDbConnection(strConn);
DataSet ds = new DataSet();
dataConn.Open();
//建立Adpater來承接select出來的DataSet
OleDbDataAdapter ta = new OleDbDataAdapter(strComm, dataConn);
ta.Fill(ds, "ExcelInfo");
abc.DataSource = ds.Tables["ExcelInfo"].DefaultView;
abc.DataBind();