0

我想将gridview导出到powerpoint。我有以下代码。但我有以下问题:

  1. 当我将它用于 ms office 2010.it 时出现错误:

    Powerpoint 无法读取 c:\users\filename.ppt。无法打开演示文稿。您的防病毒程序可能会阻止您打开演示文稿。要解决此问题,请确保您的防病毒程序是最新的并且工作正常。如果问题仍然存在并且演示文稿来自您信任的人,请关闭您的防病毒程序,然后再次尝试打开演示文稿。如果这样做,请确保在打开演示文稿后再次打开防病毒程序。

  2. 当我将它用于 ms office 2007 时,它打开但没有 gridview

代码:

       Response.Clear();

       Response.Buffer = true;

       Response.AddHeader("content-disposition", "attachment;filename=FileName.ppt");

       Response.Cache.SetCacheability(HttpCacheability.NoCache);
       Response.Charset = ""; 
     //  this.Response.ContentType = "application/vnd.openxmlformats-       officedocument.presentationml.presentation";

       this.Response.ContentType = "application/vnd.ms-powerpoint.presentation.macroEnabled.12";

       this.Response.ContentType = "application/vnd.ms-powerpoint";

    //Response.ContentType = "application/vnd.ppt";

    GridView2.AllowPaging = false; 

    GridView2.DataBind();

    System.IO.StringWriter stringWrite = new System.IO.StringWriter(); 
    System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite); 
    GridView2.RenderControl(htmlWrite);

     Response.Write(stringWrite.ToString());

   Response.End();
   Response.Flush();
4

1 回答 1

0

尝试使用外部库来生成您的 ppt 或 pptx。像 aspose.net 或 Open xml。

于 2013-01-11T10:16:39.210 回答