Write a * .doc or * .rtf file from a c / C ++ application

How can I write / generate a * .doc file programmatically using c or C ++? Is there an open source library / cross platform for this? If this is not possible, can you write the * .odt file and then convert it to * .doc? Thanks in advance!

EDIT: Anders Abel noted that the * .rtf file type is an option, so any suggestions on this subject are also accepted.

+4
source share
5 answers

Joel has an interesting article on this topic: http://www.joelonsoftware.com/items/2008/02/19.html

Basically, it offers either:

  • Use MS Word via COM to create a document.
  • Create another format that will load MS Word, for example RTF. The advantage of RTF is that it is a text format. That way, you can generate a template document with place owners, and then just start a lookup operation when you want to generate your documents.
+3
source
  • Use Microsoft Word Interop with an object interface. You must install Word.
  • Use rtf for simple things. For complex things, rtf usually fails or becomes unpleasant.
  • Consider docx. Microsoft has published tools for working with docx.
  • The Doc is open, but the spec is written for aliens. You can try chewing it.
+2
source

Instead, write an html file, which is a very simple text format. Select the file extension name as DOC. MS Word will open correctly.

+2
source

The .doc format, as you probably noticed that it is not open. A simple workaround is often to write a .rtf file that opens well in MS Word. The .rtf format is text-based and publicly documented. As long as you keep pretty simple content, writing .rtf is easy.

0
source

Source: https://habr.com/ru/post/1302653/


All Articles