【发布时间】:2018-06-10 11:20:53
【问题描述】:
我正在将 gridview 导出到 excel,这是我的代码-
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.AddHeader("content-disposition", string.Format("attachment; filename={0}", fileName));
HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);
HttpContext.Current.Response.ContentType = "application/vnd.ms-excel";
HttpContext.Current.Response.Charset = "";
HttpContext.Current.Response.Write("<meta http-equiv=Content-Type content=\"text/html; charset=windows-1250\">\n");
HttpContext.Current.Response.Write("<html xmlns:o='urn:schemas-microsoft-com:office:office'\n" +
"xmlns:x='urn:schemas-microsoft-com:office:excel'\n" +
"xmlns='http://www.w3.org/TR/REC-html40'>\n" +
"<head>\n");
在这里,我无法使列自动调整。 我很困惑并在谷歌上搜索并尝试了许多解决方案,但问题仍然存在。 任何帮助将不胜感激。 谢谢
【问题讨论】:
标签: c# asp.net excel gridview export-to-excel