GridViewToExcel(EdceExcelGV, "application/ms-exce","xxxxxx表");

protected void GridViewToExcel(Control ctrl, string FileType, string FileName)
{

/*Response.Charset = "GB2312";
Response.ContentEncoding = Encoding.UTF8;
HttpContext.Current.Response.AppendHeader("Content-Disposition",
"attachment;filename=" + HttpUtility.UrlEncode(FileName, System.Text.Encoding.UTF8).ToString());
HttpContext.Current.Response.ContentType = FileType;//image/JPEG;text/HTML;image/GIF;vnd.ms-excel/msword
this.EnableViewState=false;
StringWriter sw=new StringWriter ();
HtmlTextWriter htw=new HtmlTextWriter(sw);
ctrl.RenderControl(htw);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();*/

Response.ClearContent();
Response.BufferOutput = true;
Response.Charset = "utf-8";
Response.ContentType = FileType;
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.AppendHeader("Content-Disposition", "attachment;filename=" + Server.UrlEncode(FileName) + ".xls");
this.EnableViewState=false;
StringWriter sw=new StringWriter ();
HtmlTextWriter htw=new HtmlTextWriter(sw);
ctrl.RenderControl(htw);
HttpContext.Current.Response.Write(sw.ToString());
HttpContext.Current.Response.End();
}
public override void VerifyRenderingInServerForm(Control control)
{
}

最新文章

  1. Python学习日志(二)
  2. 【原】iOS学习之Masonry第三方约束
  3. App开放接口api安全性的设计与实现
  4. 第64课 C++中的异常处理(上)
  5. 手机web页面制作时的注意事项
  6. JavaScript 风格指导(Airbnb版)
  7. 【Java】Checked、Unchecked Exception
  8. HTML7常用的类型刮刮乐 光棒效果
  9. 优化 or 语句
  10. Java NIO系列教程(六) 多路复用器Selector
  11. 如何使用Live CD来修复Grub / Grub2
  12. HTML5中的History对象
  13. Git删除文件
  14. 结合 spring 使用阿里 Druid 连接池配置方法
  15. 在react中使用intro.js的的一些经验
  16. u3d 场景资源打包
  17. 2018.09.21 codeforces1051D. Bicolorings(线性dp)
  18. 16_常用API_第16天(正则表达式、Date、DateFormat、Calendar)_讲义
  19. [转帖] .net 2.1 是 LTS长期支持版本.
  20. Linux命令详解-printf

热门文章

  1. django使用自己的setting的方法
  2. Tomcat学习笔记【4】--- Server.xml配置文件详解
  3. 【题解】CF997C Sky Full of Stars
  4. Django 初始化数据库
  5. matplotlib和numpy 学习笔记
  6. 更新TP-LINK路由器的外网IP到花生壳动态IP解析
  7. BZOJ 3362 Navigation Nightmare
  8. python-常用内置函数与装饰器
  9. 一个关于前端页面的小标签<tbody>
  10. listen 73