vb.net2005中将gridview中的数据导出为EXECL
版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://boyi55.blog.51cto.com/4345/27297 |
vb.net2005中将gridview中的数据导出为EXECLauthor:boyi55
在按钮上定义导出EXECL事件。
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Clear() Response.Buffer = True Response.Charset = "GB2312" Response.AppendHeader("Content-Disposition", "attachment;filename=month_loginout.xls") Response.ContentEncoding = System.Text.Encoding.UTF7 Response.ContentType = "application/ms-excel" Dim oStringWriter As System.IO.StringWriter = New System.IO.StringWriter Dim oHtmlTextWriter As System.Web.UI.HtmlTextWriter = New System.Web.UI.HtmlTextWriter(oStringWriter) Me.GridView1.RenderControl(oHtmlTextWriter) Response.Output.Write(oStringWriter.ToString) Response.Flush() Response.End() End Sub '重载 VerifyRenderingInServerForm Public Overloads Overrides Sub VerifyRenderingInServerForm(ByVal control As Control)
End Sub
-------------------------------
出现错误:
只能在执行 Render() 的过程中调用 RegisterForEventValidation的错误提示。
解决方案:
直接在导出Execl的页面修改 <%@ Page Language="VB" EnableEventValidation = "false" AutoEventWireup="true" CodeFile="ExportGridView.aspx.cs" Inherits="ExportGridView" %> 本文出自 “风云” 博客,请务必保留此出处http://boyi55.blog.51cto.com/4345/27297 本文出自 51CTO.COM技术博客 |



boyi55
博客统计信息
热门文章
最新评论
友情链接
