Generating word documents (.doc/.odt) through C++/Qt

∥☆過路亽.° 提交于 2019-11-30 09:13:13

I have done this through the Qt way. i.e by using ActiveQt module.

The reference documentation for MS Word can be obtained through,

MSDN documentation, which actually pointed to the VBAWD10.chm file that has the ActiveX apis for MS Word.

The Word Application can be initialized by

QAxWidget wordApplication("Word.Application"); 

The sub-objects of the word application can be obtained through the function,

QAxBase::querySubObject()

For e.g:

QAxObject *activeDocument = wordApplication.querySubObject("ActiveDocument");

To pass the obtained sub-object as an argument,

QVariant QAxBase::asVariant () const

Any function calls involving the word object can be called using the function using,

 QAxBase::dynamicCall ()

For e.g:

activeDocument->dynamicCall("Close(void)");

After a quite good amount of struggle and few convinces, it's working fine. :)

Hope it helps for those who are all looking for similar solutions...

maybe you can use this and write to a file in odf format http://doc.trolltech.com/4.6/qtextdocumentwriter.html#supportedDocumentFormats qt does not know how to output doc docx etc but you can use com(activeQt) or some other library to write in those or other formats you need

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!