[英]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.