为什么导出excel时会把web form的其他非datagrid控件(例如Label)也导入到excel里面去?
解决方案 »
- 2个 tree的选择
- 在gridview中添加行
- error msg:"集合已修改;枚举操作可能不会执行。 "
- 我要做一个在线VOD系统,跪求源代码!(50)
- 网页文件名自动编号是怎么回事儿?进者有分!
- ASP.NET做的聊天室的聊天数据用什么存?
- 用frameset设计页面的问题?
- Server.方法 只能用在 aspx 或 ascx 后台页面吗?
- dropdownlist指定显示
- 大家快来讨论一下在asp.net环境下Word.Applacation的启动条件?
- 关于多项目整合的问题,请指教!!!!!!!
- 请问如何在aspx.cs程序里修改datagrid的hyperlinkcolumn的url属性(比如DataNavigateUrlFormatString)
ctl.Visible=true;
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=Excel.xls");//!
string tt=HttpContext.Current.Response.ContentType;
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("GB2312");
HttpContext.Current.Response.ContentType ="application/ms-excel/ms- word";//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
// ctl.Page.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new HtmlTextWriter(tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write("<meta http-equiv=Content-Type content=text/html;charset=gb2312>");
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
ctl.Page.EnableViewState = true;
ctl.Visible=CurrCtlVisible;
搞到我郁闷死了。不知问题出在哪里,同样调用一个函数却有不同效果。
在加一个Response.BufferOutput=true;试一下