首页 > 代码库 > 如何读取ppt内容

如何读取ppt内容

1、java版本
public string PptReader(string filename)
{
string fullname = DocPath+filename; //绝对路径
PowerPoint.Application papp = new PowerPoint.Application();
PowerPoint.Presentation ppr = papp.Presentations.Open(fullname, Microsoft.Office.Core.MsoTriState.msoCTrue,
MsoTriState.msoFalse, MsoTriState.msoFalse);
string doc = "";
foreach (PowerPoint.Slide slide in ppr.Slides)
{
foreach (PowerPoint.Shape shape in slide.Shapes)
{
if (shape.HasTextFrame. == MsoTriState.msoTrue)
{
if (shape.TextFrame.HasText == MsoTriState.msoTrue)
{
doc += shape.TextFrame.TextRange.Text.ToString();
doc += "/n";
}
}

}
}

ppr.Close();
System.Runtime.InteropServices.Marshal.ReleaseComObject(ppr);
ppr = null;
papp.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(papp);
papp = null;
return doc;
}

后续提供javascript如何读取ppt,欢迎交流!

如何读取ppt内容