日期:2014-05-18 浏览次数:20410 次
string _excelconnstr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + Server.MapPath(@"ExportInExcel/" + _newfilename + ".xls") + ";Extended Properties='Excel 8.0;HDR=Yes;IMEX=1;'"; OleDbConnection oledbconn = new OleDbConnection(_excelconnstr); oledbconn.Open(); OleDbCommand command = new OleDbCommand("SELECT * FROM [Sheet1$]", oledbconn); OleDbDataAdapter adp = new OleDbDataAdapter(command); adp.Fill(ds); oledbconn.Close(); this.GridView1.DataSource = ds.Tables[0]; this.GridView1.DataBind();