zoukankan      html  css  js  c++  java
  • 【Vegas原创】VB.NET版Excel导出(GridView、DataGrid通吃)

    在click事件中加入:

          Protected Sub imgExcel_Click(ByVal sender As ObjectByVal e As System.Web.UI.ImageClickEventArgs) Handles imgExcel.Click
                Response.Clear()
                Response.Buffer 
    = True
                Response.Charset 
    = "GB2312"
                Response.AppendHeader(
    "Content-Disposition""attachment;filename=FileName.xls")
                
    '如果设置为 GetEncoding("GB2312");导出的文件将会出现乱码!!!

                Response.ContentEncoding 
    = System.Text.Encoding.UTF7
                Response.ContentType 
    = "application/ms-excel" '/设置输出文件类型为excel文件。 

                
    Dim oStringWriter As New System.IO.StringWriter()
                
    Dim oHtmlTextWriter As New System.Web.UI.HtmlTextWriter(oStringWriter)
                
    '  turn off paging 
                grdeap.AllowPaging = False
                grdeap.Columns(
    0).Visible = False
                
    '注意:不是grdeap.databind()
                mydatabind()
                grdeap.RenderControl(oHtmlTextWriter)
                Response.Output.Write(oStringWriter.ToString())
                Response.Flush()
                Response.End()

            
    End Sub


     

  • 相关阅读:
    HttpClient Coder Example
    HttpClient容易忽视的细节—连接关闭
    Hibernate中所有包作用详细讲解
    Commons-VFS 使用SFTP
    Ant 编译项目资源不足
    ActiveMQ介绍和ActiveMQ入门实例
    ActiveMQ与MSMQ的异同
    linux nohup命令详解
    linux sed命令详解
    linux iptables命令详解
  • 原文地址:https://www.cnblogs.com/amadeuslee/p/3744574.html
Copyright © 2011-2022 走看看