如何在 C++ 中创建 OpenOffice 文档

发布于 2024-11-03 11:39:39 字数 493 浏览 4 评论 0原文

可能的重复:
从 C++ 创建、打开和打印 Word 文件

你好,

我需要从 C++ 程序创建一个 Word 文档, 我使用的是Windows 2008服务器,办公自动化有时会在这里失败,而且我还需要非交互式服务来处理,因为自动化提供了交互式服务。我已经实现了自动化,它有时会失败

我可以通过哪些方式创建openoffice/word文档?

您能否建议我任何链接或教程来执行上述操作。

PS - 我开始了解几种方法 1.Openoffice SDK 2.OpenXML SDK

如果您使用过上述方法,请建议我使用上述哪种方法。

提前致谢

Possible Duplicate:
Creating, opening and printing a word file from C++

Hi,

I need to create a word document from a c++ program,
Im using windows 2008 server,office automation fails sometimes here and also I need non interactive service to handle as automation provides interactive service.I've implemented automation it fails sometimes

What are the ways I can create openoffice / word doc?

can you please suggest me any links or tutorials to do the above.

PS - I came to know about couple of methods 1.Openoffice SDK 2.OpenXML SDK

If you have worked with the above please suggest me which of the above to use.

Thanks in advance

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

小糖芽 2024-11-10 11:39:39

这是一个新发布的名为 libOPC 的 C 库,它与 Open XML SDK 具有相同的意图,但可以在所有 Linux/Windows/Mac/etc 中使用。您可以在这里阅读:libOPC 版本 0.0.1 发布 并从 CodePlex 获取代码(请务必查看文档页面以获取演示视频)。

Here's a newly released C library called libOPC which has the same intent as the Open XML SDK, but can be used in all of Linux/Windows/Mac/etc. You can read about it here: libOPC version 0.0.1 released and get the code from CodePlex (be sure to check the documentation page for demo videos).

一百个冬季 2024-11-10 11:39:39

如果您的目标是 Word 2007 及更高版本,那么直接使用 Open Office XML SDK 和 Open Office XML 是不错的选择。

如果您的目标用户是 Word 2003 及更早版本,那么它可能不是最佳选择。但是,即使这些用户也可以安装免费过滤器,以便能够在 Word 2003 中打开 Word 2007 (.docx) 文档。您可以从应用程序链接到此下载。大多数使用 Word 2003 或更早版本的人可能都安装了此过滤器,因为他们经常会遇到人们共享较新文件的情况。

http://www .microsoft.com/DOWNLOADS/en/details.aspx?familyid=941b3470-3ae9-4aee-8f43-c6bb74cd1466&displaylang=en

Open Office XML SDK 是一个 .NET API,用于读写 .docx 和其他 Office 2007年档案。如果您使用 C++/CLI,那么您可以轻松使用它,它将简化编写 .docx 文件的过程。

http://www .microsoft.com/downloads/en/details.aspx?FamilyId=C6E744E5-36E9-45F5-8D8C-331DF206E0D0&displaylang=en

但是,如果您使用没有 .NET 的直接 C++,则无法使用SDK。但这并不是一个巨大的损失。无论如何,SDK 只是 XML 文件的一个非常小的包装。 docx 文件只是一个包含一堆 XML 文件的 zip 文件。文件之间的关系、文本存储位置以及某些内容如何按位置而不是通过 id 引用的方式存在一些奇怪之处,这通常被认为是 XML 的一种非常糟糕的做法。不管怎样,这些问题很容易解决,您可以手动创建 .docx 文件,而不会遇到太多麻烦。事实上,创作比阅读容易得多。

SDK 仍然很有用,因为它包含一个文件浏览工具,可以为您提供现有文件的图形浏览器。当您想知道如何创建特定内容时,请在 Word 2007 中执行此操作,保存文件,然后查看文件包含的内容。

Using the Open Office XML SDK and Open Office XML directly are good options if you're targeting Word 2007 and up.

If you're targeting users of Word 2003 and earlier then it may not be the best option. However, even those users can install a free filter to be able to open Word 2007 (.docx) documents within Word 2003. You can link to this download from your application. Most people with Word 2003 or earlier probably have this filter installed anyways since they will often run into situations where people share newer files.

http://www.microsoft.com/DOWNLOADS/en/details.aspx?familyid=941b3470-3ae9-4aee-8f43-c6bb74cd1466&displaylang=en

Open Office XML SDK is a .NET API for reading and writing .docx and other Office 2007 files. If you're using C++/CLI then you can use this easily enough and it will simplify the process of writing .docx files.

http://www.microsoft.com/downloads/en/details.aspx?FamilyId=C6E744E5-36E9-45F5-8D8C-331DF206E0D0&displaylang=en

However, if you're using straight C++ with no .NET, then you cannot use the SDK. This isn't a huge loss though. The SDK is only a very slight wrapper around the XML files anyways. A docx file is just a zip with a bunch of XML files inside. There are some oddities in relationships between the files and where text is stored and how some things are referenced positionally instead of by ids, which is generally considered a very bad practice with XML. Regardless though, those issues are easily worked around and you can create .docx files manually without too much trouble. In fact, creating is much easier than reading.

The SDK is still useful in that it contains a file exploration tool that will give you a graphical explorer for existing files. When you want to know how to create particular content, do it within Word 2007, save the file, and then look at what the file contains.

心的位置 2024-11-10 11:39:39

我建议您查看此页面,其中作者解释了他采取的解决方案在服务器上生成 Word 文档,无需使用 MsWord,无需自动化或第三方库。

I advise you to look at this page where the author explains what solution he took to generate Word documents on a server, without MsWord being available, without automation or thirdparty libraries.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文