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

            }
  • 相关阅读:
    解决spring boot JavaMailSender部分收件人错误导致发送失败的问题
    Linux设备驱动开发基础--内核定时器
    Linux中断分层--工作队列
    Linux中断分层--软中断和tasklet
    深入理解函数线程安全与可重入
    Linux中断处理流程
    Linux混杂设备驱动--按键设备驱动
    Linux字符设备驱动--Led设备驱动
    Linux字符设备简单示例
    Linux内核硬件访问技术
  • 原文地址:https://www.cnblogs.com/pw/p/583890.html
Copyright © 2011-2022 走看看