C# 如何在ASP.NET MVC中读取PPT文件?
我在桌面上有一个名为“slide.PPT”的PPT文件。我想在我的C# 如何在ASP.NET MVC中读取PPT文件?,c#,asp.net,asp.net-mvc-4,powerpoint,C#,Asp.net,Asp.net Mvc 4,Powerpoint,我在桌面上有一个名为“slide.PPT”的PPT文件。我想在我的ReadSlide功能中阅读此PPT文件的所有幻灯片,如下所示 public void ReadSlide(){ } 如何在C代码中读取PPT文件中的所有幻灯片?如果是PPTX,您可以使用OpenXML读取。因为你特别要求PPT,所以有点难 您肯定不应该使用自动化/互操作,因为 这意味着您必须使用第三方工具来阅读PPT。如果你用谷歌搜索它们,你会看到一长串。我从未使用过它,但它似乎做得很好。使用如下 public void
ReadSlide
功能中阅读此PPT文件的所有幻灯片,如下所示
public void ReadSlide(){
}
如何在C代码中读取PPT文件中的所有幻灯片?如果是PPTX,您可以使用OpenXML读取。因为你特别要求PPT,所以有点难 您肯定不应该使用自动化/互操作,因为 这意味着您必须使用第三方工具来阅读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 + " ";
}
}
}
}
看看这个。如果您定义“阅读幻灯片”的含义,可能会有所帮助。您不应该在服务器进程中使用自动化。