解决方案 »
- asp.net 下大家一般都用什么图表控件?
- 求moneybookers接口相关知识,能像paypal一样接收支付结果吗?
- C# 复制 粘贴
- 我用的是access数据库,想用sql语句查询,可是系统老是提示出错,该怎么办
- 问几个关于.net比较麻烦的概念性问题,大家帮忙(高手请进)
- 请教版主:如何在C#里用键盘CTRL+ENTER触发一个按钮的事件
- CKeditor 上传图片如何修改默认上传页 求javascript高手,急 ###
- 打包高手请进,打包完成后运行有错
- 请问怎么向 html 中的 table 里写入数据?马上结贴,谢谢!
- ashx 怎样获取GET方式发来的Json数据
- 如何 在 web服务中 获得 服务页面的 真实url?
- 关于ListView
{
string strFileNames = DateTime.Now.ToShortDateString();
ToExcel(this.RecordToolbar1, strFileNames);
}
public static void ToExcel(System.Web.UI.Control col, string fname)
{
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
//Context.Current.Response.Clear();
HttpContext.Current.Response.Charset = "gb2312";
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("utf-7");
HttpContext.Current.Response.ContentType = "application/ms-excel";
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + "" + HttpUtility.UrlEncode(fname, System.Text.Encoding.UTF8) + ".xls");
col.Page.EnableViewState = false;
System.IO.StringWriter tw = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter hw = new System.Web.UI.HtmlTextWriter(tw);
col.RenderControl(hw);
HttpContext.Current.Response.Write(tw.ToString());
HttpContext.Current.Response.End();
}
{
Response.Charset = "UTF-8"; //设置编码的 Response.ContentEncoding = System.Text.Encoding.UTF8; Response.Write("<meta http-equiv=Content-Type content=text/html;charset=utf-8>"); Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode(filename) + ".xls"); Response.ContentType = "application/excel"; StringWriter sw = new StringWriter(); HtmlTextWriter htw = new HtmlTextWriter(sw); gv.RenderControl(htw); Response.Write(sw.ToString()); Response.End();
}