从excel导出数据时发生错误

时间:2010-12-01 04:44:47

标签: export-to-excel

将数据导出到Excel工作表时出错。

代码

Response.Clear()
Response.AddHeader("content-disposition",   "attachment;filename=CompletionDatesReport.xls")
Response.Charset = ""
Response.Cache.SetCacheability(HttpCacheability.NoCache)
Response.ContentType = "application/vnd.xls"
Dim stringWrite As StringWriter = New StringWriter()
Dim htmlWrite As HtmlTextWriter = New HtmlTextWriter(stringWrite)
gridData.RenderControl(htmlWrite)
Response.Write(stringWrite.ToString())
Response.End()

错误

  

Internet Explorer无法从www.xyz.com下载abc.aspx   Internet Explorer无法打开此网站。请求的网站不可用或无法找到。请稍后再试。

1 个答案:

答案 0 :(得分:1)

删除第4行

Response.Cache.SetCacheability(HttpCacheability.NoCache)

这将是有效的。