opensuse安装QtXlsxWriter库实现QT操作excel文件

Odele ·
更新时间:2024-09-22
· 615 次阅读

由于工作需要大量处理xlsx文件,在网上找到了这个库,QtXlsxWriter的项目地址

https://github.com/dbzhang800/QtXlsxWriter

使用它可以远离微软的office环境,单独操作xlsx表格文件。

@1 下载 QtXlsxWriter 

@2 我的系统默认自带perl。

Note: Perl is needed in this step.
Download the source code.
Put the source code in any directory you like
Go to top directory of the project in a terminal and run
    qmake
    make
    make install

解压之后进入目录中make的时候出现错误

xlsxzipreader.cpp: In member function ‘void QXlsx::ZipReader::init()’:
xlsxzipreader.cpp:51:66: error: conversion from ‘QVector’ to non-scalar type ‘QList’ requested
   51 |     QList allFiles = m_reader->fileInfoList();
      |                                            ~~~~~~~~~~~~~~~~~~~~~~^~
make[2]: *** [Makefile:2476: .obj/xlsxzipreader.o] Error 1
make[2]: Leaving directory '/home/mt/Downloads/QtXlsxWriter-master/src/xlsx'
make[1]: *** [Makefile:45: sub-xlsx-make_first] Error 2
make[1]: Leaving directory '/home/mt/Downloads/QtXlsxWriter-master/src'
make: *** [Makefile:47: sub-src-make_first] Error 2

参考文章https://blog.csdn.net/woshidahuaidan2011/article/details/52724452

找到xlsxzipreader.cpp文件添加

#include

把QList改成QVector编译通过。

@3

Add following line to your qmake's project file:
    QT += xlsx
Then, using Qt Xlsx in your code
    #include 
    int main()
    {
        QXlsx::Document xlsx;
        xlsx.write("A1", "Hello Qt!");
        xlsx.saveAs("Test.xlsx");
        return 0;
    }

用官网上的代码测试确认此库可用。


作者:mengtianwxs



opensuse

需要 登录 后方可回复, 如果你还没有账号请 注册新账号