zoukankan      html  css  js  c++  java
  • Excel的导出操作

    下面的代码展示了如何将Excel内容显示到GridView中:
    aspx代码:

    .aspx

    .cs代码:
    protected void btnImport_Click(object sender, EventArgs e)
            
    {
                
    string Path = f_path.Value;
                
    string strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + Path + ";" + "Extended Properties=Excel 8.0;";
                OleDbConnection conn 
    = new OleDbConnection(strConn);
                conn.Open();
                
    string strExcel = "";
                OleDbDataAdapter myCommand 
    = null;
                DataSet ds 
    = null;
                strExcel 
    = "select * from [sheet1$]";
                myCommand 
    = new OleDbDataAdapter(strExcel, strConn);
                ds 
    = new DataSet();
                myCommand.Fill(ds, 
    "table1");

                gv_list.DataSource 
    = ds;
                gv_list.DataBind();

            }
  • 相关阅读:
    POJ 2186 Popular Cows
    POJ 1364 King
    poj1811
    poj1404
    poj1781
    poj1386
    poj1442
    C#中调用IE打开某文档
    【观点】什么时候学习编程都不晚
    遍历DataTable内存数据的三种方法性能对比
  • 原文地址:https://www.cnblogs.com/pw/p/583890.html
Copyright © 2011-2022 走看看