System.Web.HttpContext.Current.Response.Clear()
System.Web.HttpContext.Current.Response.Buffer = True
System.Web.HttpContext.Current.Response.Charset = "GB2312"
Dim s As String
s = "attachment;filename=" + HttpUtility.UrlEncode(strFileName, System.Text.Encoding.UTF8)
Dim aType As String
Select Case aFileType
Case 0 'excle
s = s + ".xls"
aType = "application/ms-excel"
Case 1 'word
s = s + ".doc"
aType = "application/ms-word"
Case 2 'TXT 暂时不用
s = s + ".txt"
aType = "application/ms-txt"
Case 3 'html
s = s + ".html"
aType = "application/ms-html"
End Select
System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", Trim(s))
System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312")
application/ms-txt、application/ms-html 或其他浏览器可直接支持文档
System.Web.HttpContext.Current.Response.ContentType = aType
Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter
Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter)
aGridView.AllowPaging = False
aGridView.AllowSorting = False
aGridView.DataBind()
aGridView.RenderControl(oHtmlTextWriter)
System.Web.HttpContext.Current.Response.Output.Write(oStringWriter.ToString)
System.Web.HttpContext.Current.Response.Flush()
System.Web.HttpContext.Current.Response.End()
System.Web.HttpContext.Current.Response.Clear() System.Web.HttpContext.Current.Response.Buffer = True System.Web.HttpContext.Current.Response.Charset = "GB2312" Dim s As String s = "attachment;filename=" + HttpUtility.UrlEncode(strFileName, System.T