从Excel导出数据,绑定DataGrid的方法string strConn = "Provider=Microsoft.Jet.Oledb.4.0;Data Source=" + Server.MapPath("products.xls"+ ";Extended Properties=Excel 8.0"
从Excel导出数据,绑定DataGrid的方法            OleDbConnection conn 
= new OleDbConnection(strConn);
从Excel导出数据,绑定DataGrid的方法            OleDbDataAdapter adp 
= new OleDbDataAdapter("Select * from [Sheet1$]",conn);//Sheet1是Excel的名称
从Excel导出数据,绑定DataGrid的方法
            DataSet ds = new DataSet();
从Excel导出数据,绑定DataGrid的方法            adp.Fill(ds,
"Products");
从Excel导出数据,绑定DataGrid的方法            ExlDataGrid.DataSource 
= ds.Tables["Products"].DefaultView;
从Excel导出数据,绑定DataGrid的方法            ExlDataGrid.DataBind();

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-01-04
  • 2022-12-23
  • 2021-08-09
  • 2021-12-03
  • 2022-12-23
  • 2021-09-30
猜你喜欢
  • 2021-12-12
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-02
相关资源
相似解决方案