简体   繁体   English

在没有Word Automation的情况下,在Delphi中读取/解析/修改MS Word文档

[英]Read/Parse/Modify MS Word document in Delphi without Word Automation

Does anyone know any good library (free or commercial) for Delphi that can read/parse/modify MS Word documents (preferably with Word 2007 support) without MS Word OLE Automation? 有没有人知道Delphi的任何好的库(免费或商业)可以在没有 MS Word OLE自动化的情况下读取/解析/修改MS Word文档(最好是Word 2007支持)? I've found some for .Net, but none for Delphi. 我找到了一些用于.Net,但没有用于Delphi。

For example, here are two .Net/Java libraries - Aspose , Word.net 例如,这里有两个.Net / Java库--AsposeWord.net

I don't want to add .Net dependencies in my application. 我不想在我的应用程序中添加.Net依赖项。 A library that compiles right inside the exe will be most preferable, but any ActiveX will also work. 最好在exe内部编译的库是最好的,但任何ActiveX都可以工作。

Thank you. 谢谢。

I know (a simple non-commercial) variant for Excel, but not for Word. 我知道(一个简单的非商业)Excel的变体,但不是Word。 And not for very new ones. 而不是非常新的。

DR: the problem is that that needs Word installed. DR:问题是需要安装Word。 The options above don't. 上面的选项没有。 Moreover OLE can get slow, eg when you want to make umpteen personal letters for a mailing in it. 此外,OLE可能会变慢,例如,当您想在其中发送无数个人信件时。

The only other routine I can imagine is automating Open Office. 我能想象的唯一其他例程就是自动化Open Office。 But that has the same speed problems (or worse) probably, so that would depend on why you exactly want this. 但是这可能会有相同的速度问题(或更糟),所以这取决于你为什么要这么做。

The Office format is horribly complicated, and nearly every solution will be more expensive (in either vast time or money) than just coughing up a copy of word. 办公室格式非常复杂,几乎每种解决方案都会比咳出一个字副本更昂贵(无论是花费大量时间还是金钱)。 (and with OOo you could even avoid that) (和OOo你甚至可以避免这种情况)

Scalabium has TSMWordDocument component that can extract the plain text and is entirely in native code. Scalabium具有TSMWordDocument组件,可以提取纯文本并完全使用本机代码。 It doesn't support modifying them or extracting graphics/styles though. 它不支持修改它们或提取图形/样式。 Their SM Export component set allows generating Word documents, but I don't think it supports reading them. 他们的SM Export组件集允许生成Word文档,但我认为它不支持读取它们。 We use the TSMWordDocument one and it's ridiculously fast compared to COM automation. 我们使用TSMWordDocument,与COM自动化相比,它的速度非常快。 The only downside we've hit is that it even though it's Delphi 2009 compatible, it still doesn't handle international text unless the system codepage matches (so Japanese on a Japanese system is ok, but not on an English one). 我们遇到的唯一缺点就是即使它与Delphi 2009兼容,它仍然不会处理国际文本,除非系统代码页匹配(因此日语系统上的日语可以,但不是英语系统)。

Microsoft's formats are so complex that it is a lot of work to write, and keep up to date, a set of components to do what you want without automation. 微软的格式非常复杂,需要编写并保持最新的一系列组件,以便在没有自动化的情况下执行您想要的操作。

There is Winsoft's Office Component Suite , but you'll see that hasn't been updated to work with the latest version of Office, or with Delphi 2009+. Winsoft的Office组件套件 ,但您会看到尚未更新以使用最新版本的Office或Delphi 2009+。

You could use the .NET library and create an ActiveX/COM wrapper for it, which you can use from Delphi. 您可以使用.NET库并为其创建一个ActiveX / COM包装器,您可以从Delphi中使用它。

This article describes the interop possibilities between COM and .NET. 本文介绍COM和.NET之间的互操作可能性。 Look at "Using .NET Objects from COM" 看看“从COM使用.NET对象”

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM