如何在Windows的qt中使用QAxObject创建docx和doc文件?

问题描述 投票:2回答:1

如何创建新的'doc'和'docx'文件,并在Windows的'qt'中使用'QAxObjectin'编写文本。我尝试使用“ https://forum.qt.io/topic/74254/how-to-read-and-write-docx-files-in-qt”,但找不到答案,因为它打开了现有文件,但我想创建一个新文件。

c++ qt docx doc
1个回答
0
投票

您可以使用您提到的链接中的代码,而无需做任何修改:

 QFile fileout("abc.docx");
 if(!fileout.open(QFile::WriteOnly | QFile::Text))
     qDebug()<< "Could not open file";

 QTextStream out(&fileout);
 QString text = "hello world";
 out << text;
 fileout.flush();
 fileout.close();

这是您需要的吗?

© www.soinside.com 2019 - 2024. All rights reserved.