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


     

  • 相关阅读:
    学习shell脚本
    Python 3.3.2 round函数并非"四舍五入"
    Python 通过继承实现标准对象的子类
    Python 继承标准类时发生了什么
    Python 表示无穷大的数
    用Python最原始的函数模拟eval函数的浮点数运算功能(2)
    Python 函数参数*expression 之后为什么只能跟关键字参数
    RE模块疑问
    用Python最原始的函数模拟eval函数的浮点数运算功能
    Python 好用得让人发指的函数参数语法糖
  • 原文地址:https://www.cnblogs.com/amadeuslee/p/3744574.html
Copyright © 2011-2022 走看看