是否可以在 C# 中获取 PPT 的幻灯片 html。
以及如何在使用互操作创建演示文稿的同时使用 html 创建新幻灯片?
您可以从 PPT 文件中读取并从每张幻灯片中获取文本,请参见下面的示例:
static void Main(string[] args)
{
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(@"C:\PPT\myPowerpoint.pptx");
string presentation_text = "";
for (int i = 0; i < presentation.Slides.Count; i++)
{
foreach (var item in presentation.Slides[i+1].Shapes)
{
var shape = (PowerPoint.Shape)item;
if (shape.HasTextFrame == MsoTriState.msoTrue)
{
if (shape.TextFrame.HasText == MsoTriState.msoTrue)
{
var textRange = shape.TextFrame.TextRange;
var text = textRange.Text;
presentation_text += text+" ";
}
}
}
}
PowerPoint_App.Quit();
Console.WriteLine(presentation_text);
}