如何替换 PowerPoint (.ppt) 文档中的文本?
有哪些解决方案? 我只知道用 Apache POI 替换 Word (.doc) 文件中的书签的解决方案?
是否还可以更改 .doc 和 .ppt 文档中的图像、布局、文本样式?
我考虑替换 Word 和 PowerPoint 文档中的区域以进行批量处理。
平台:MS-Office 2003
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
您的平台有哪些限制?
显然 Apache POI 至少可以帮助您完成部分任务。
Microsoft 自己的 COM API 相当强大,并在此处进行了记录。 如果 a)您没有在服务器(许多用户,多线程)环境中运行; b) 您可以在生产机器上安装适当版本的 powerpoint; c) 您可以针对 COM 对象模型进行编码。
What are your platform limitations?
Obviously Apache POI will get you at least part of the way there.
Microsoft's own COM API's are fairly powerful and are documented here. I would recommend using them if a) you are not running in a server (many users, multithreaded) environment; b) you can have a proper version of powerpoint installed on the production machine; and c) you can code against a COM object model.
它有点贵,但是 Aspose.Slides 是一个非常强大的用于操作 PowerPoint 文件的库
It's a bit pricey, but Aspose.Slides is a very powerful library for manipulating PowerPoint files
如果您选择使用其他 Office 套件,则以下是可能的解决方案列表:
使用 POI,您无法编辑 .pptx 文件格式,但您不依赖于系统上安装的应用程序。 相反,其他两个选项使用其他应用程序,但它们肯定更适合处理演示文稿。 顺便说一句,OpenOffice 与旧格式具有更好的兼容性。 另外,如果您使用 UNO,您将有多种语言选择,UNO 适用于 Java、C++、Python 和其他语言。
If you include using other Office suits as an option, here's a list of possible solutions:
Using POI you can't edit .pptx file format, but you don't depend on the apps installed on the system. Other two options, on the contrary, make use of other apps, but they are definitely better for dealing with presentations. OpenOffice has better compability with older formats, by the way. Also if you use UNO, you'll have a great choice of languages, UNO exists for Java, C++, Python and other languages.
我的经验并不是直接使用 Power Point,但我实际上已经推出了自己的 WordML (XML) 生成器。 它 a) 消除了对 Word 的所有依赖,b) 速度非常快,c) 让我从头开始构建文档。
但创造起来需要做很多工作。 我只是创建一个只写实现。
我对 Power Point 不太熟悉,所以这是推测,但您可以通过阅读 XML(Power Point 2003?)和/或破解 Office Open XML 文件(压缩的 XML)来推出自己的推测,然后使用XPath 来操作数据,然后将所有内容保存回磁盘。
但这不适用于基于旧版 OLE 复合文档的 Power Point 文件。
My experience is not directly with Power Point, but I've actually rolled my own WordML (XML) generator. It a) removed all dependencies on Word, b) was very fast c) and let me build up documents from scratch.
But it was a lot of work to create. And I was only creating a write only implementation.
I'm not as familiar with Power Point, so this is conjecture, but you may be able to roll your own by reading XML (Power Point 2003??) and/or cracking the Office Open XML file (zipped XML), then using XPath to manipulate the data, and then saving everything back to disk.
This won't work on older OLE Compound Document based Power Point files though.
我以前做过类似的事情:以编程方式访问和操作 PowerPoint 演示文稿。 当我这样做时,一切都是使用 COM 的 C++ 语言,但类似的原则也适用于 C#/VB .NET 应用程序,因为它们非常容易进行 COM 互操作。
您正在寻找的称为 Office 文档模型。 基本上,Office 应用程序以编程方式公开其文档,作为定义其内容的对象树。 这些对象可通过 API 访问,您可以操作它们、添加新对象以及执行您想要的任何其他处理。 它的威力极其强大; 您可以使用它来操作文档的几乎所有方面。 但您需要安装 Office 和 Visual Studio 才能使用它。
一些链接:
希望这有帮助!
I've done something like that before: programmatically accessed and manipulated PowerPoint presentations. Back when I did it, it was all in C++ using COM, but similar principles apply to C#/VB .NET apps, since they do COM interop very easily.
What you're looking for is called the Office Document Model. Basically, Office applications expose their documents programmatically, as trees of objects that define their contents. These objects are accessible via an API, and you can manipulate them, add new ones, and do whatever other processing you want. It's exceedingly powerful; you can use it to manipulate pretty much all aspects of a document. But you'll need an installation of Office and Visual Studio to be able to use it.
Some links:
Hope this helps!
显然,新用户每次发帖只能包含一个链接。 多么蹩脚啊! :)
这是我打算包含的另一个链接:
Apparently new users can only include one link per posting. How lame! :)
Here's the other link I meant to include: