Handling Microsoft Word file format: Difference between revisions

From Qt Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 8: Line 8:




<pre style="background-color: #E6E6FA">Note that this information is collaboratively collected by the community, with no promise
 
{| style="background-color:LightCyan;" cellpadding="20" cellspacing="0" border="1"
| Note that this information is collaboratively collected by the community, with no promise
of completeness or correctness. In particular, use your own research and judgment
of completeness or correctness. In particular, use your own research and judgment
when evaluating third-party libraries or tools!</pre>
when evaluating third-party libraries or tools!
|}


One needs to distinguish between two different formats (this page deals with both of them):
One needs to distinguish between two different formats (this page deals with both of them):
Line 92: Line 95:
Files using the XML-based (.docx) format could be processed using Qt's XML handling classes (see [[Handling_Document_Formats | Handling Document Formats]]).
Files using the XML-based (.docx) format could be processed using Qt's XML handling classes (see [[Handling_Document_Formats | Handling Document Formats]]).


<pre style="background-color: moccasin"> TODO: Expand this section.</pre>
{| style="background-color:moccasin;" cellpadding="20" cellspacing="0" border="1"
| TODO: Expand this section.
|}


=== Using batch conversion tools ===
=== Using batch conversion tools ===
Line 135: Line 140:
=== Using Word itself ===
=== Using Word itself ===


<pre style="background-color: moccasin">TODO: If you know whether Word provides a "viewer" ActiveX control that can be embedded in a Qt application through ActiveQT, please fill out
{| style="background-color:moccasin;" cellpadding="20" cellspacing="0" border="1"
this section (include links to relevant resources!) </pre>
| TODO: If you know whether Word provides a "viewer" ActiveX control that can be embedded in a Qt application through ActiveQT, please fill out
this section (include links to relevant resources!)
|}


=== Manual solution ===
=== Manual solution ===
<pre style="background-color: moccasin">TODO: Tips for implementing a custom Microsoft Word viewer widget, using Qt and the Microsoft Word parsing libraries mentioned above </pre>
{| style="background-color:moccasin;" cellpadding="20" cellspacing="0" border="1"
 
| TODO: Tips for implementing a custom Microsoft Word viewer widget, using Qt and the Microsoft Word parsing libraries mentioned above
|}





Revision as of 08:24, 25 March 2015



This page discusses various available options for working with Microsoft Word documents in your Qt application. Please also read the general considerations outlined on the Handling Document Formats page.


Note that this information is collaboratively collected by the community, with no promise

of completeness or correctness. In particular, use your own research and judgment when evaluating third-party libraries or tools!

One needs to distinguish between two different formats (this page deals with both of them):


Legacy "Word Document" format "Office Open XML Document" format
classification: binary XML-based
main filename extension: .doc .docx
main internet media type: application/vnd.ms-word application/vnd.openxmlformats-officedocument.wordprocessingml.document
default format of Word: until Word 2003 since Word 2007

Reading / Writing

Using Word itself

If you are exclusively targeting the Windows platform and Microsoft Word will be installed on all target machines, then you can use Qt’s ActiveX framework to access Word’s .doc and .docx processing functionality through OLE automation. For an introductory code example (and a way to list the API provided by Word's COM object), consult this how to (focuses on Microsoft Excel, but it works the same way for Word).

DLL file name COM object name platforms license
Microsoft Word ? Word.Application Windows commercial

Using independent parser/writer libraries

API .doc .docx reading writing platforms license
wv C yes no yes no Win, Mac, Linux GPL [strong copyleft]

Using manual XML processing

Files using the XML-based (.docx) format could be processed using Qt's XML handling classes (see Handling Document Formats).

TODO: Expand this section.

Using batch conversion tools

If all else fails, there is always the option of using an existing tool to automatically convert between Microsoft Word files and a more manageable format, and let your Qt application deal with that format instead. The conversion tool could be bundled with your application or specified as a prerequisite, and controlled via Doc:QProcess. Some possibilities are:


.doc to .docx to … to .doc … to .docx platforms
AbiWord .txt .rtf .html .dbk .odt .docx … .txt .rtf .html .dbk .odt … - .txt .rtf .html .dbk .odt .doc … Win, Mac, Linux, …
wvWare .txt .rtf .html .dbk … - - - Win, Mac, Linux, …

Notes:

AbiWord can be used like this for batch conversion:

abiword to=outputfile.rtf inputfile.doc

Displaying / User-Interacting

Using Word itself

TODO: If you know whether Word provides a "viewer" ActiveX control that can be embedded in a Qt application through ActiveQT, please fill out

this section (include links to relevant resources!)

Manual solution

TODO: Tips for implementing a custom Microsoft Word viewer widget, using Qt and the Microsoft Word parsing libraries mentioned above


See Also