请问怎么回事?
我调用的类是 public static void Export(System.Web.UI.Control ctl, int nDestType)
{
string header;
string contenttype;
switch( nDestType )
{
case 0:
header = "attachment;filename=memory.xls";
contenttype = "application/ms-excel";
break;
case 1:
header = "attachment;filename=memory.doc";
contenttype = "application/msword";
break;
case 2:
header = "attachment;filename=memory.html";
contenttype = "text/HTML";
break;
default:
header = "attachment;filename=memory.html";
contenttype = "text/HTML";
break;
}
HttpContext.Current.Response.Charset ="utf-8";
HttpContext.Current.Response.AppendHeader("Content-Disposition",header);
HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.GetEncoding("utf-8");
//HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.GetEncoding("GB2312");
HttpContext.Current.Response.ContentType = contenttype;
ctl.Page.EnableViewState =false;
System.IO.StringWriter tw = new System.IO.StringWriter() ;
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter (tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}
我调用的类是 public static void Export(System.Web.UI.Control ctl, int nDestType)
{
string header;
string contenttype;
switch( nDestType )
{
case 0:
header = "attachment;filename=memory.xls";
contenttype = "application/ms-excel";
break;
case 1:
header = "attachment;filename=memory.doc";
contenttype = "application/msword";
break;
case 2:
header = "attachment;filename=memory.html";
contenttype = "text/HTML";
break;
default:
header = "attachment;filename=memory.html";
contenttype = "text/HTML";
break;
}
HttpContext.Current.Response.Charset ="utf-8";
HttpContext.Current.Response.AppendHeader("Content-Disposition",header);
HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.GetEncoding("utf-8");
//HttpContext.Current.Response.ContentEncoding =System.Text.Encoding.GetEncoding("GB2312");
HttpContext.Current.Response.ContentType = contenttype;
ctl.Page.EnableViewState =false;
System.IO.StringWriter tw = new System.IO.StringWriter() ;
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter (tw);
ctl.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}
解决方案 »
- NetworkStream networkStream = tcpClient.GetStream();怎么读取换行
- 求教啊:查出数据后,怎样通过单击,来选中某一条数据,然后得到该条数据的ID主键?
- 文本框初始值不存入数据库
- Table中显示不同数据源的数据,怎么实现?
- 如何解决Div的偏移问题?
- 我的网站aspl.net的,数据库sqlserver(放在内网)想通过tomcat连接数据库,该如何做呢???急!!!
- 使用SqlHelper.ExecuteDataset查询存储过程,返回参数的问题
- 在水晶报表中如何在一个页中打印2条同样的记录。
- 各位兄弟们iis 服务器都是好好的 为什么 再打开的时候 居然显示 403.9连接错误 谁能帮忙解决一下
- 如何在DataGrid上设置某些列(是动态产生的列)可以直接修改。在线。
- InitializeComponent()的问题
- 如何提取DataGrid1中某单元格的值?
或者身份证号码 后面全部 + 一个空字符窜
我记得孟子的网站上有,看看去吧
http://dotnet.aspx.cc/
http://dotnet.aspx.cc/Exam/OutPutExcel.aspx