Usage(1): Use Xlsx as Qt5’s addon module
1. Download the source code from github.com.
https://github.com/dbzhang800/QtXlsxWriter/archive/master.zip
- Put the source code in any directory you like. At the toplevel directory run
Note: Perl is needed in this step.
qmake
make
make install
The library, the header files, and others will be installed to your system.
注:编译时会出现如下错误:
xlsxzipreader.cpp: In member function ‘void QXlsx::ZipReader::init()’:
xlsxzipreader.cpp:51:66: error: conversion from ‘QVector’ to non-scalar type ‘QList’ requested
QList allFiles = m_reader->fileInfoList();
解决方法:
1.打开出错的源文件
vim src/xlsx/xlsxzipreader.cpp
2.添加头文件#include ,然后把出错的地方的”QList” 用”QVector” 替换掉重新make就可以了。
- Add following line to your qmake’s project file:
QT += xlsx
4. Then, using Qt Xlsx in your code
include “xlsxdocument.h”
int main()
{
QXlsx::Document xlsx;
xlsx.write(“A1”, “Hello Qt!”);
xlsx.saveAs(“Test.xlsx”);
return 0;
}

本文档指导如何将Xlsx作为Qt5的附加模块进行安装与使用。首先从GitHub下载源代码并进行编译安装,解决编译过程中可能出现的错误。安装完成后,通过示例代码展示如何创建和保存Excel文件。

5955

被折叠的 条评论
为什么被折叠?



