gpt4 book ai didi

.net - 在不使用 Office Automation 的情况下生成 PowerPoint 演示文稿的一些技术有哪些?

转载 作者:行者123 更新时间:2023-12-02 22:26:09 25 4
gpt4 key购买 nike

虽然可以generate PowerPoint presentations automatically using Office Automation ,这是not recommended for use on a server 。如何在不使用 Office Automation 的情况下生成 PowerPoint 演示文稿?

最佳答案

另一个没有提到的选项,也是我们最终采取的路线,是利用 Open XML Office 2007 和 Office XP 中通过 compatibility pack 直接支持的文件格式。使用Open XML SDK 1.0事实证明,让某些东西发挥作用出人意料地简单。

首先,准备一个通用模板文件,并用 token 代替需要替换的内容。接下来,需要将对 DocumentFormat.OpenXml 的引用添加到项目中。代码本身将引用 DocumentFormat.OpenXml 和 DocumentFormat.OpenXml.Packaging 命名空间。最后,循环播放幻灯片的代码如下所示:

// Open the presentation
PresentationDocument presentation = PresentationDocument.Open(fileName, true);
// Loop through all of the slides in the presentation
foreach (SlidePart slide in presentation.PresentationPart.SlideParts)
{
// Read the XML out of the slide
XmlDocument xml = new XmlDocument();
xml.Load(slide.GetStream());

// TODO: Your XML manipulation code here

// Save the updated slide
xml.Save(slide.GetStream());
}
// Save the updated presentation
presentation.Close();

关于.net - 在不使用 Office Automation 的情况下生成 PowerPoint 演示文稿的一些技术有哪些?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/825247/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com