本文介绍了如何在ASP.NET MVC中读取PPT文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在桌面上有一个名为 slide.ppt的PPT文件。我想在下面的 ReadSlide
函数中读取此PPT文件的所有幻灯片
I have PPT file on desktop named as "slide.ppt". I want to read all slides of this PPT file in my ReadSlide
function as below
public void ReadSlide(){
}
如何从CPT代码中的PPT文件中读取所有幻灯片?
How can I read all slide from a PPT file in my C# code?
推荐答案
按以下方式使用
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 + " ";
}
}
}
}
这篇关于如何在ASP.NET MVC中读取PPT文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!