在Asp.net中将GridView打印为word或者Excel
2008-12-11 18:50
483 查看
在Asp.net中将GridView打印为word或者Excel
学到的新东东,GridView打印为word,呵呵
1.打印按钮函数
2.必须再写这个函数
3.在.aspx页面page里边加上
上面这三步是必须的
学到的新东东,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(); }//打印输出按钮 |
1 2 3 | public override void VerifyRenderingInServerForm(System.Web.UI.Control control) { } |
1 | EnableEventValidation="false" |
相关文章推荐
- 在Asp.net中将GridView打印为word或者Excel
- 在Asp.net中将GridView打印为word或者Excel
- 在ASP.NET中将GridView数据导出到Word、Excel
- 使用ASP.NET的GridView导出/儲存資料至Excel,Word,Txt檔,Powerpoint
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- 在ASP.NET中将dataset数据保存到excel,GridView导出到excel
- 使用ASP.NET的GridView导出/儲存資料至Excel,Word,Txt檔,Powerpoint
- ASP.NET中数据库数据导入Excel、Word并打印
- ASP.NET中将数据输出到WORD、EXCEL、TXT、HTM
- ASP.NET中将数据输出到WORD、EXCEL、TXT、HTM
- asp.net中将DataGrid数据导出到excel或word文件中
- [转]ASP.NET中将GridView 导出到Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0中将 GridView 导出到 Excel 文件中
- ASP.NET 2.0,C#----利用GridView控件导出其他文件(导出Excel,导出Word文件)
- asp.net中将DataGrid数据导出到excel或word文件中
- ASP.NET 2.0,C#----利用GridView控件导出其他文件(导出Excel,导出Word文件)
- ASP.NET中将数据输出到WORD、EXCEL、TXT、HTM
- asp.net提示关于word或者excel组件问题