在Asp.net中将GridView打印为word或者Excel
来源:互联网 发布:蓝牙控制小车app源码 编辑:程序博客网 时间:2024/06/05 17:36
在Asp.net中将GridView打印为word或者Excel
在Asp.net中将GridView打印为word或者Excel
学到的新东东,GridView打印为word,呵呵
1.打印按钮函数
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
protected void Button_print_Click(object sender, EventArgs e) { System.Web.HttpContext HC = System.Web.HttpContext.Current; HC.Response.Clear(); HC.Response.Charset = "GB2312"; HC.Response.Buffer = true; HC.Response.ContentEncoding = System.Text.Encoding.UTF7; HC.Response.AddHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("查询结果打印", System.Text.Encoding.UTF8) + ".doc"); HC.Response.ContentType = "application/ms-word";//如果要打印为excel格式,则换为"application/excel" this.EnableViewState = false; System.IO.StringWriter sw = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htw = new System.Web.UI.HtmlTextWriter(sw); this.GV_result.RenderControl(htw); HC.Response.Write(sw.ToString()); HC.Response.End(); }//打印输出按钮
2.必须再写这个函数
1
2
3
public override void VerifyRenderingInServerForm(System.Web.UI.Control control) { }
3.在.aspx页面page里边加上
1
EnableEventValidation="false"
文章来源:http://www.cnblogs.com/lan0725/archive/2008/12/11/1873900.html
0 0
- 在Asp.net中将GridView打印为word或者Excel
- 在Asp.net中将GridView打印为word或者Excel
- 在ASP.NET中将dataset数据保存到excel,GridView导出到excel
- .net中将GridView中的部分内容或者全部内容导出到Excel
- asp.net gridview 生成excel及word
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- iOS 取出网页缓存与网页离线缓存
- java连接数据库(查询语句)
- MongoDB Shell 常用操作命令
- java基础(四)------ jdbc连接数Oracle数据库步骤及示例!
- 第3章:TTCN-3基础-笔记
- 在Asp.net中将GridView打印为word或者Excel
- 统计学习方法——k近邻法
- 淘宝图片放大镜JavaScript效果
- 如何严格设置php中session过期时间
- 配置文件lighttpd.conf参数详细说明的链接和选译
- C#与C/C++的交互
- Count Palindrome in String
- 【Python】Python Assert 为何不尽如人意
- 浅谈C++普通指针和智能指针管理动态内存的陷阱