用 C++ 读取 .docx

2021-12-31 00:00:00 file-io docx ms-word c++

我正在尝试创建一个读取 .docx 文件并将其内容发布到博客/论坛供个人使用的程序.我终于想出了如何使用 libcurl 来做(我认为)是程序中最难的部分.现在我只需要阅读 .docx 文件,但遇到了麻烦.我似乎找不到有关如何执行此操作的任何文档.有什么想法吗?

I'm trying to create a program that reads a .docx file and posts it content to a blog/forum for personal use. I finally have figured out how to use libcurl to do (what I figured) was the harder part of the program. Now I just have to read the .docx file, but have come under a snag. I can't seem to find any documentation on how to do this. Any ideas?

推荐答案

最简单的方法是使用 Word 来执行此操作.它对许可有限制.

The easiest way is to use Word to do this. It has limitations on licensing.

SO 问题 创建、打开和打印 word 文件来自 C++ 有一些很好的参考.

The SO question Creating, opening and printing a word file from C++ has some good references.

根据这些问题/答案可以解压Open XML文件并直接处理XML文件:

According to these questions/answers can unzip the Open XML file and process the XML file directly:

  • 如何读取 Word 2007 .docx 文件?

如果您使用 .NET,还有更多 (C#) 问题需要阅读:

If you use .NET there are more (C#) questions to read:

  • 如何从 word 中抓取文本 (docx)C#中的文档?
  • 如何在 C# (.NET) 中加载 MS Word 文档)?
  • 我如何以编程方式使用C# 将多个 DOCX 文件附加在一起?

相关文章