概要:.NET开发office应用。
环境:Windows Server 2000. .Net Framework2.0 无OFFICE.
功能:功能是解析PPT/PPTX(获取每一个slide里面的文本内容).
实现:
建立Console Applicatioin. 
添加引用:
 1. Microsoft Office 11.0 Object Library.
 2. Microsoft PowerPoint 11.0 Object Library.发布出来之后放到服务器上不能正常使用。因为服务器没有安装过OFFICE,也不允许安装。.NET里面有什么什么方法可以直接解析PPT/PPTX,然后发布出来的应用是可以“独立运行”的么?也就是说发布的时候会带上所需要的底层库文件。如果您知道,请尽量说的详细些。
谢谢。参考源码:namespace ConsoleApp
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();
            try
            {
                
                PowerPoint.Application app = new PowerPoint.Application();
                PowerPoint.Presentation presentations = app.Presentations.Open(Environment.CurrentDirectory.ToString()+"\\test.pptx", Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoTrue, Microsoft.Office.Core.MsoTriState.msoFalse);
                foreach (PowerPoint.Slide slide in presentations.Slides)
                {
                    foreach (PowerPoint.Shape shape in slide.Shapes)
                    {
                        if (shape.TextFrame.HasText == Microsoft.Office.Core.MsoTriState.msoTrue)
                        {
                            sb.Append(shape.TextFrame.TextRange.Text);                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.WriteLine(sb.ToString());
            Console.WriteLine("-- Finished!\nPress enter to exit.");
            Console.ReadLine();
        }
    }
}

解决方案 »

  1.   

    你可以用Aspose.Slides组件,不需安装office就可以操作PPT了,不过要购买Aspose.Slides的license.
    我现在遇到的问题跟你的差不多, 现在是用Aspose.Slides操作PPT,用户要求在生成的PPT中插入一个Presentation的OleObject对象,用来显示一些数据, 但是使用Aspose.Slides生成一个PPT文件,然后再用AddOleObjectFrame方法添加到主要的PPT文件中的时候,OleObject对象总是打不开.
    但是如果用Micrososft Power Point Presentation去生成一个PPT, 再用AddOleObjectFrame添加到主PPT的时候,是OK的.我现在也是苦于没有解决方法, 用MS Power Point必须要安装Office,即使是添加引用Microsoft.Office.Interop.PowerPoint.dll. 哪位大牛有好的解决办法.