日期:2014-05-19  浏览次数:20489 次

datagrid导出Excel表问题,迷惑!
用一下代码在同一个程序里面,有的可以导出为Excel,有的只能导出为HTML文件,不知何故?哪位高手能解释一下?
                Dim   tw   As   New   System.IO.StringWriter
                Dim   hw   As   New   System.Web.UI.HtmlTextWriter(tw)
                dgexcel.RenderControl(hw)
                Dim   response   As   System.Web.HttpResponse   =   System.Web.HttpContext.Current.Response
                response.Clear()
                response.ContentEncoding   =   System.Text.Encoding.GetEncoding( "utf-8 ")
                response.ContentType   =   "application/vnd.ms-excel;charset=GBK "
                response.AddHeader( "Content-Disposition ",   "attachment;   filename=ExcelFile ")
                response.Charset   =   "gb2312 "
                response.Write(tw.ToString())
                response.End()


------解决方案--------------------
http://www.codeproject.com/aspnet/ExportClassLibrary.asp
------解决方案--------------------
我顶 顶顶顶顶