QAxObject wrod合并单元格 C++
时间: 2023-11-14 20:09:10 浏览: 38
可以使用QAxObject来操作Word,以下是合并单元格的示例代码:
```cpp
QAxObject* word = new QAxObject("Word.Application");
QAxObject* documents = word->querySubObject("Documents");
QAxObject* document = documents->querySubObject("Open(const QString&)", "your_document_path");
QAxObject* tables = document->querySubObject("Tables");
QAxObject* table = tables->querySubObject("Item(int)", 1); //第一个表格
QAxObject* cell = table->querySubObject("Cell(int,int)", 1, 1); //第一个单元格
QAxObject* merge_range = table->querySubObject("Cell(int,int)", 2, 2); //要合并的单元格范围
QAxObject* range = table->querySubObject("Range(QAxObject*, QAxObject*)", cell, merge_range);
range->dynamicCall("Merge()");
```
注意:需要在项目的.pro文件中添加`QT += axcontainer`以支持ActiveX控件。
相关推荐
![txt](https://img-home.csdnimg.cn/images/20210720083642.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)