zoukankan      html  css  js  c++  java
  • 将gridview 导出到excel

    在前台加个按钮 Btn_ExportExcel,然后在后台加上以下的函数

    Protected Sub Btn_ExportExcel_Click1(ByVal sender As Object, ByVal e As System.EventArgs) Handles Btn_ExportExcel.Click                          Response.Charset = "utf-8"

            Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312")

     

            Response.ClearContent()

            Response.AddHeader("content-disposition", "attachment; filename=" & System.Web.HttpUtility.UrlEncode("new", System.Text.Encoding.UTF8) & ".xls")

            Response.ContentType = "application/excel"

     

            Dim sw As New StringWriter

            Dim htw As New HtmlTextWriter(sw)

           //此句中指定 gridview 控件

            Main_grdv.RenderControl(htw)

             Response.Write(sw.ToString)

            Response.End()    

    End

    //不加此函数会报错

    Sub     Public Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)

    End Sub

  • 相关阅读:
    java基础(二):补充
    java基础(二):变量和数据类型
    C基础系列(一)
    java基础(一)
    循环小数(Repeating Decimals)
    DNA序列(DNA Consensus String)
    sqlserver~创建函数
    docker简介和安装
    JMeter(6)、实现Java请求
    JMeter(5)、测试数据库
  • 原文地址:https://www.cnblogs.com/withoutaword/p/2544647.html
Copyright © 2011-2022 走看看