visual basic .net 将GridView表中的数据导出到excel
怎样将visualbasic.net2005中GridView表中的数据导出到excel中,具体步骤和编码。谢谢...
怎样将visual basic .net 2005中GridView表中的数据导出到excel中,具体步骤和编码。谢谢
展开
2个回答
展开全部
Public Shared Sub Out(p As Page, c As Control)
p.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8")
p.Response.Charset = ""
p.Response.ContentType = "application/vnd.ms-excel"
p.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(tw)
p.Response.AppendHeader("Content-Disposition", "attachment;filename=" & HttpUtility.UrlEncode("汇总报表.xls", System.Text.Encoding.UTF8))
c.RenderControl(hw)
p.Response.Write(tw.ToString())
p.Response.[End]()
End Sub
这是一个类 直接引用就可以了
p.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8")
p.Response.Charset = ""
p.Response.ContentType = "application/vnd.ms-excel"
p.EnableViewState = False
Dim tw As New System.IO.StringWriter()
Dim hw As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(tw)
p.Response.AppendHeader("Content-Disposition", "attachment;filename=" & HttpUtility.UrlEncode("汇总报表.xls", System.Text.Encoding.UTF8))
c.RenderControl(hw)
p.Response.Write(tw.ToString())
p.Response.[End]()
End Sub
这是一个类 直接引用就可以了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询