我在桌面上有名为“ slide.ppt”的PPT文件。我想在我的ReadSlide函数中读取此PPT文件的所有幻灯片,如下所示

public void ReadSlide(){


}


如何在C#代码中从PPT文件读取所有幻灯片?

最佳答案

用途如下

public void ReadSlide(){

            string filePath= @"C:\Users\UserName\Slide.pptx";

            Microsoft.Office.Interop.PowerPoint.Application PowerPoint_App = new Microsoft.Office.Interop.PowerPoint.Application();
            Microsoft.Office.Interop.PowerPoint.Presentations multi_presentations = PowerPoint_App.Presentations;
            Microsoft.Office.Interop.PowerPoint.Presentation presentation = multi_presentations.Open(filePath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);

            string presentation_textforParent = "";
            foreach (var item in presentation.Slides[1].Shapes)
            {
                var shape = (Microsoft.Office.Interop.PowerPoint.Shape)item;
                if (shape.HasTextFrame == MsoTriState.msoTrue)
                {
                    if (shape.TextFrame.HasText == MsoTriState.msoTrue)
                    {
                        var textRange = shape.TextFrame.TextRange;
                        var text = textRange.Text;

                        presentation_textforParent += text + " ";
                    }
                }
            }
}

关于c# - 如何在ASP.NET MVC中读取PPT文件?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/29006417/

10-12 05:38