本文介绍了在Asp.net 4.0中将GridView导出到Powerpoint 2007的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 嗨开发者, 在我的Web应用程序中,我的要求是将网格视图导出到PowerPoint 2007. 我在Google上尝试了很多文章,但是没有成功。 我尝试将网格视图转换为.bmp图像然后导出到ppt。没有成功。 在这种情况下,我正在丢失网格中网格的颜色和文本的宽度。 亲切的帮助我这个问题,这是现在的主要要求。 如果您知道任何免费的第三方工具,请通知我。解决方案 我应该假设这些链接都不适合你吗? 在asp.net中将GridView导出到Powerpoint [ ^ ] 将代码放入按钮点击事件 GridView1.AllowPaging = false ; /// /////仅在启用分页时才编写此代码。 GridView1.DataBind(); /// /////仅编写此代码如果启用了分页。 Response.Clear(); Response.AddHeader( content-disposition, attachment; filename = FileName.ppt); /// ////用于文本文件写入FileName.txt Response.Charset = ; // 如果您希望选项打开Excel文件而不保存 // 注释掉下面一行 // Response.Cache.SetCacheability(HttpCacheability.NoCache); Response.ContentType = application / vnd.ppt; \\\\\ for text file write vnd.txt System.IO.StringWriter stringWrite = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); GridView1.RenderControl(htmlWrite); Response.Write(stringWrite.ToString()); Response.End(); GridView1.AllowPaging = true ; /// /////仅在启用分页时才编写此代码。 GridView1.DataBind(); /// /////仅在启用分页时才编写此代码。 您必须覆盖 VerifyRenderingInServerForm的功能喜欢这 public 覆盖 void VerifyRenderingInServerForm(控制控件) { /// 保持空白 } 为避免异常,你必须设置属性 < ![CDATA [<%@ 页面 语言 = C# EnableEventValidation = false % > Hi Developers,In My web application, my requirement is to export grid view to PowerPoint 2007.I tried many articles in Google, but there is no successful.I tried with converting grid view to .bmp image then export to ppt. no success.In this case,I am loosing the colors of the grid and width of the text inside the grid.Kindly help me out this issue, this is the major requirement now.If you know any free third party tools to export kindly let me know. 解决方案 Should i assume none of these links worked for you?Export GridView to Powerpoint in asp.net[^]put code in button click eventGridView1.AllowPaging = false; ////////write this code only if paging is enabled.GridView1.DataBind();////////write this code only if paging is enabled.Response.Clear();Response.AddHeader("content-disposition", "attachment;filename=FileName.ppt");///////for text file write FileName.txtResponse.Charset = "";// If you want the option to open the Excel file without saving than// comment out the line below// Response.Cache.SetCacheability(HttpCacheability.NoCache);Response.ContentType = "application/vnd.ppt";\\\\\for text file write vnd.txtSystem.IO.StringWriter stringWrite = new System.IO.StringWriter();System.Web.UI.HtmlTextWriter htmlWrite =new HtmlTextWriter(stringWrite);GridView1.RenderControl(htmlWrite);Response.Write(stringWrite.ToString());Response.End();GridView1.AllowPaging = true; ////////write this code only if paging is enabled.GridView1.DataBind();////////write this code only if paging is enabled.You will have to override function of VerifyRenderingInServerForm like thispublic override void VerifyRenderingInServerForm(Control control){///Keep it empty}And to avoid exception you have to set property of<![CDATA[<%@ Page Language="C#" EnableEventValidation="false" %> 这篇关于在Asp.net 4.0中将GridView导出到Powerpoint 2007的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-23 23:42