在c#中将gridview导出到microsoft powerpoint

时间:2013-01-11 09:51:07

标签: asp.net

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

  1. 当我在ms office 2010中使用它时。给出错误:

      

    Powerpoint无法读取c:\ users \ filename.ppt。演示文稿不能   被打开了。您的防病毒程序可能会阻止您打开   介绍。要解决此问题,请确保您的防病毒程序是   当前和正常工作。如果问题仍然存在,那么   演示文稿来自您信任的人,关闭您的防病毒软件   程序,然后尝试再次打开演示文稿。如果你这样做,   确保在打开后再次打开防病毒程序   介绍

  2. 当我在ms office 2007中使用它时,它的开放但没有gridview

  3. CODE:

           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();
    

1 个答案:

答案 0 :(得分:0)

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