![](/img/trans.png)
[英]Response.AppendToLog() doesn't append anything in IIS7, Windows Server 2008
[英]Export to excel - Issue on Windows Server 2008 IIS7
我正在尝试导出到Excel中的repeter / Gridview, this is working fine in my local machine and windows server 2003, however when I deployed on Windows server 2008 its not working properly
。 这是我的代码
StringWriter sw = new StringWriter();
HtmlTextWriter htw = new HtmlTextWriter(sw);
string attachment = "attachment; filename=myReport.xls";
Response.ClearContent();
Response.AddHeader("content-disposition", attachment);
Response.ContentType = "application/vnd.ms-excel";
rpt.RenderControl(htw);
Response.Write(sw.ToString());
Response.Flush();
Response.End();
服务器详细信息: Windows Server 2008和IIS7
在mozilla中,所有页面内容都会错误导出到excel,但在IE&Chrome中,空的excel文件将导出而没有数据。
您正在将字符串写入响应。 我希望此文件类型是二进制文件,因此您应该使用Response.BinaryWrite()。 rpt.RenderControl(htw)实际上是什么? 我怀疑您应该将内容类型更改为text / csv,而excel仍然可以处理。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.