我无法在 IE 8 中导出到 excel。我不断收到以下信息:“IE 无法从 url 下载 filename.aspx。” “IE 无法打开此 Internet 站点。请求的站点不可用或找不到。请再试一次”
在我看来,它忽略了 https,并试图打开 http,但我可能是错的。根据这篇文章:http: //support.microsoft.com/kb/323308
我的代码是:
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
gvResources.RenderControl(htw);
Response.ClearContent();
Response.ClearHeaders()
Response.AddHeader("Content-Disposition", "attachment; filename=AdHocReport.xls");
Response.ContentType = "application/vnd.ms-excel";
Response.Write(sw.ToString());
Response.End();