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

            }
  • 相关阅读:
    proxool数据库连接池用法
    SQL Server 用链接server 同步MySQL
    使用DNSCrypt解决Dropbox污染问题
    POJ 1952 BUY LOW, BUY LOWER DP记录数据
    使用doxygen为C/C++程序生成中文文档
    构造器(二)----指定构造器、便利构造器
    Spring Boot 部署与服务配置
    排序算法c语言描述---冒泡排序
    【转】Android Studio系列教程一--下载与安装
    【转】Windows环境下Android Studio v1.0安装教程
  • 原文地址:https://www.cnblogs.com/pw/p/583890.html
Copyright © 2011-2022 走看看