Response.Clear();
Response.Buffer= true;
Response.Charset="GB2312";
string strFileName = Server.UrlPathEncode("监测报表") + "(" + this.txtStatisticDate.Text.Trim() + ")";
Response.AppendHeader("Content-Disposition","attachment;filename=" + strFileName + ".xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("gb2312");
Response.ContentType = "application/ms-excel";
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.lblReport.RenderControl(oHtmlTextWriter);
string strTmp = oStringWriter.ToString();
strTmp = strTmp.Replace("border=0","border=1");
strTmp = strTmp.Replace("height=23","height=18");
Response.Write(strTmp);
Response.End();结果就是乱码,但有的时候是好的,好的情况下感觉表格数据量少,所以我推测是HTML文本太长导致的,大家帮忙亚,为什么如此的不稳定?谢谢!
Response.Buffer= true;
Response.Charset="GB2312";
string strFileName = Server.UrlPathEncode("监测报表") + "(" + this.txtStatisticDate.Text.Trim() + ")";
Response.AppendHeader("Content-Disposition","attachment;filename=" + strFileName + ".xls");
Response.ContentEncoding=System.Text.Encoding.GetEncoding("gb2312");
Response.ContentType = "application/ms-excel";
this.EnableViewState = false;
System.IO.StringWriter oStringWriter = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter oHtmlTextWriter = new System.Web.UI.HtmlTextWriter(oStringWriter);
this.lblReport.RenderControl(oHtmlTextWriter);
string strTmp = oStringWriter.ToString();
strTmp = strTmp.Replace("border=0","border=1");
strTmp = strTmp.Replace("height=23","height=18");
Response.Write(strTmp);
Response.End();结果就是乱码,但有的时候是好的,好的情况下感觉表格数据量少,所以我推测是HTML文本太长导致的,大家帮忙亚,为什么如此的不稳定?谢谢!
解决方案 »
- string保留两位小数点. 有难度!
- 亚马逊网站图书列表动态查询与产品条数统计技术问题
- visual stdio2005与Oracle的链接问题
- 日期与时间处理问题
- sql视图排序出问题
- 根据坐标,动态放置图像位置
- :) 呵呵,刚学asp.net,哪位大哥帮帮忙!
- Asp 做新闻系统 可以用HTML+模版标签的形式 制作模版。
- vs2005里怎么单独把一个cs编译成dll?
- 求ie web control的msi版本,问:如何部署一个asp.net程序,里面有ie web control,crystal report,和一个第三方控件c1的。
- 谁有异步加载MS TreeView 的代码。
- .NET建站求助!~~~~~~~~请高手指教
http://community.csdn.net/Expert/topic/4570/4570895.xml?temp=.4458887