当前位置:网站首页>QT :QAxObject操作Excel
QT :QAxObject操作Excel
2022-06-30 19:20:00 【B!GGer.】
QT += axcontainer #include <QAxObject>
QString filePath = QDir::toNativeSeparators(_filePath);
QAxObject *excel = new QAxObject();//建立excel操作对象
excel->setControl("Excel.Application");//连接Excel控件
excel->setProperty("Visible", false);//显示窗体看效果
excel->setProperty("DisplayAlerts", false);//显示警告看效果
QAxObject *workbooks = excel->querySubObject("WorkBooks");//获取工作簿(excel文件)集合
workbooks->dynamicCall("Open(const QString&)", filePath);
QAxObject *workbook = excel->querySubObject("ActiveWorkBook");//获取当前工作簿
QAxObject *worksheet = workbook->querySubObject("WorkSheets(int)", 1);
QAxObject* cell = worksheet->querySubObject("Cells(int, int)", 1, 1);//获取单元格
QVariant cellValue = cell->property("Value");//获取值
cell->setProperty("Value", QVariant(uuid));//设置值
workbook->dynamicCall("Save()"); //保存文件
workbook->dynamicCall( "Close(Boolean)", false);//关闭文件
excel->dynamicCall("Quit(void)");//关闭excel
delete excel;边栏推荐
- Tupu software has passed CMMI5 certification| High authority and high-level certification in the international software field
- [solved] how does Tiktok cancel paying attention to the cancelled account
- Go language learning tutorial (10)
- 将 EMQX Cloud 数据通过公网桥接到 AWS IoT
- Promise from recognition to use
- neo4j load csv 配置和使用
- 事件队列、微任务与宏任务的理解和面试题
- SSM整合流程(整合配置、功能模块开发、接口测试)
- Idle fish is hard to turn over
- 达梦数据库重新初始化实例操作记录
猜你喜欢

Taiwan SSS Xinchuang sss1700 replaces cmedia cm6533 24bit 96KHz USB audio codec chip

Promise从认识到使用

Growth summer challenge is coming, exclusive community welfare is coming ~ get CSDN customized T-shirt for free

企业中通过组策略管理Edge浏览器设置(IE模式、主页绑定等)

Force deduction ----- count the string containing the given prefix

History, selection strategy and in-depth evaluation of note taking software

Idle fish is hard to turn over

FH6908A负极关断同步整流模拟低压降二极管控制IC芯片TSOT23-6超低功耗整流器 1w功耗 <100uA静态 替代MP6908

4.3寸触控屏12路控制端口可编程网络中控支持5台中控主机相互备份

VR全景中特效是如何编辑的?细节功能如何展示?
随机推荐
盘点华为云GaussDB(for Redis)六大秒级能力
pycharm从安装到全副武装,学起来才嗖嗖的快,图片超多,因为过度详细!
What securities dealers recommend? In addition, is it safe to open a mobile account?
【多线程】使用线程池、实现一个简单线程池
码蹄集 - MT3111· 赋值
FH6908A负极关断同步整流模拟低压降二极管控制IC芯片TSOT23-6超低功耗整流器 1w功耗 <100uA静态 替代MP6908
Task04: set operation - addition and subtraction of tables, join, etc. - learning notes of Tianchi Longzhu project SQL training camp
8 - 函数
内存数据库如何发挥内存优势?
matlab Delaunay 三角剖分内的查询点
Ten percent of the time, the tar command can't parse the English bracket "()" when decompressing the file
条件编译
Configure server environment
Why must a digital transformation strategy include continuous testing?
笔记软件的历史、选择策略以及深度评测
闲鱼难“翻身”
pycharm有用快捷键
Why do more and more people choose cloud rendering?
实现各种效果和功能的按钮,读这篇文章就够了
Convert seconds to * * hours * * minutes