导入Excel数据

private void Bind()
     {
   string connString=String.Format("data source={0};provider=microsoft.jet.oledb.4.0;extended properties=excel 8.0",Server.MapPath("ExcelFiles/chengji.xls"));
   OleDbConnection conn=new OleDbConnection(connString);
   conn.Open();
   OleDbCommand cmd=new OleDbCommand("select * from [sheet1$]",conn);
   OleDbDataReader dataReader=cmd.ExecuteReader();
   DataGrid1.DataSource=dataReader;
   DataGrid1.DataBind();
   conn.Close();
  }
原文地址:https://www.cnblogs.com/zhuawang/p/798145.html