简介
安装需要
1.需要安装Perl
perl5地址:Perl Download - www.perl.org
2.下载QXlsx源码并编译
下载地址:https://github.com/dbzhang800/QtXlsxWriter
- 参考文章:
Qt5下Qxlsx模块安装及使用_qt5xlsx-CSDN博客
Qt5 mingw32 mingw64使用Qxlsx模块操作Excel,免装Office,附资源&例程下载_mingw怎么做一个表格界面-CSDN博客
Qt Xlsx使用教程、Qt操作Excel、Qt生成Excel图表、跨平台不依赖Office_qtxlsx-CSDN博客
感觉最后一个链接比较全,可以参考
-
另一种使用方式
Qt Excel读写 QXlsx的安装配置以及测试 - 一杯清酒邀明月 - 博客园
测试是否安装成功
pro文件如何引入
pro文件,主要是新增了QT += xlsx
QT += core gui
QT += xlsx
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
main.cpp
#include "mainwindow.h"
#include <QApplication>
#include "stable.h"
#include <iostream>
#include <QtXlsx/xlsxdocument.h>
#include <QtXlsx/QtXlsx>
using namespace std;
int main(int argc, char *argv[])
{
cout<<"test"<<endl;
// /*定义读取函数*/
QXlsx::Document xlsx;
xlsx.write("A1", "Hello Qt!");
xlsx.saveAs("Test.xlsx");
return 0;
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
cmake如何引入
待测试。。。