• 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();

            }
  • 相关阅读:
    J2EE开发环境
    Java核心api
    SCJP (SUN认证Java程序员)
    蓝领”变“金领”
    阿飞正传
    高效项目的七个习惯转载
    写程序的一些感想和教训(转载)
    学习的过程也是迭代的过程
    管理的艺术
    怎样成为优秀的软件模型设计者?[精华]
  • 原文地址:https://www.cnblogs.com/pw/p/583890.html
Copyright © 2020-2023  润新知