zoukankan      html  css  js  c++  java
  • 控件導出EXCEL

    Private Sub ToExcel()
            
            '定義導出的EXCEL名
            Dim rnd As Random
            rnd = New Random
            Dim excelName As String
            excelName = DateTime.Now.ToString("yyyymmddhhmmss_") + rnd.Next(1000).ToString + ".xls"

            Response.Clear()
            Response.Buffer = True
            Response.Charset = "utf-8"

            Response.AppendHeader("content-disposition", "attachment;filename=" + excelName)
            Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-8")
            Response.ContentType = "application/ms-excel"
            Me.EnableViewState = False

            Dim sw As System.IO.StringWriter
            sw = New System.IO.StringWriter

            Dim hw As System.Web.UI.HtmlTextWriter
            hw = New System.Web.UI.HtmlTextWriter(sw)

            me.RenderControl(hw)
            'me為要導出的控件名稱

            Response.Write(sw.ToString)
            Response.End()

        End Sub

  • 相关阅读:
    高可用keepalived的抢占式与非抢占式
    keepalived搭建
    高可用概念
    Nginx优雅显示错误页面
    Nginx调整上传文件大小
    nginx的root和alias区别
    nginx的include
    每日总结2.18
    每日总结2.17
    每日总结2.16
  • 原文地址:https://www.cnblogs.com/Ammy/p/737611.html
Copyright © 2011-2022 走看看