小弟用Excel对象在服务器端生成excel但是现在只能在硬盘上生成,现在不需要他在硬盘上生成 而是直接输出到客户端 谢谢
解决方案 »
- 两个ntext数据类型的字段怎么相加?用+就出错,应该怎么连接呢?
- B/s系统+条形码问题
- 关于 DataTable 添加数据问题!
- CSDN的回复刷新速度是不是应该提高一点了
- 关于获取用户控件HTML代码的问题(非定制控件)肯定要高手了
- 关于 .net 和 DIV 网页布局问题,请各位高手进
- 求救:我更改了数据层中类文件路径和命名空间......
- ***不看会后悔,程序集问题***
- 请教关于dropdownlist的取值问题,请大家帮帮忙。万分感谢!
- IIS设置。怎么让别人访问本地网站 在线等!!!
- 关于IE打开ASP网页时显示原代码的问题
- 散分 同时免费发布自制的asp.net2.0弹出式下拉日历控件
Page.Response.Clear();//清空
Page.Response.Buffer = true;//缓冲输出
Page.Response.Charset = "UTF-8";
Page.Response.AppendHeader("Content-Disposition","attachment;filename = Nodedata.xls"); Page.Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8");
Page.Response.ContentType = "application/ms-excel";
this.EnableViewState = false;
//定义一个输入流
System.IO.StringWriter StrWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter HtmlTextWriter = new HtmlTextWriter(StrWrite);
Page.Response.Write(strHeader);
this.DataGrid1.RenderControl(HtmlTextWriter);
Page.Response.Write(StrWrite.ToString());
Page.Response.End();
{
BindData(); Response.ContentType = "application/vnd.ms-excel";
Response.AddHeader("Content-Disposition", "inline;filename="
+ HttpUtility.UrlEncode("下载文件.xls",Encoding.UTF8 ) ); StringBuilder sb=new StringBuilder();
System.IO.StringWriter sw = new System.IO.StringWriter(sb);
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(sw);
sb.Append("<html><body>");
dgShow.RenderControl(hw);
sb.Append("</body></html>");
Response.Write(sb.ToString());
Response.End();
}