Qt下Excel报表生成的又一利器----QtXlsxWriter
来源:互联网 发布:淘宝好评评语怎么删除 编辑:程序博客网 时间:2024/06/06 01:49
项目主页:
http://qtxlsx.debao.me/
Git地址:
https://github.com/dbzhang800/QtXlsxWriter
最近要做QT下的报表生成,本来想自己手写HTML生成再做一个转换,动手前搜了一下相关的库,还真有不少,
LIBXL,basicExcel等等。但若基于QT开发,QtXlsxWriter与之衔接十分方便,于是便下载下来试试,确实好用。
首先 确保安装了QT
配置QMAKE环境变量
export PATH="/qt installed dir/bin":$PATH
git clone https://github.com/dbzhang800/QtXlsxWriter
qmake
(sudo) make install
sudo 视QT安装目录权限决定
QT中的.pro加入第二行语句
QT += core gui
QT += xlsx
头文件加入
#include "xlsxdocument.h"
命名空间为:QXlsx
试试以下的代码
QXlsx::Document xlsx; Format format; format.setHorizontalAlignment(Format::AlignHCenter); format.setVerticalAlignment(Format::AlignVCenter); xlsx.write("A1", "Caption"); xlsx.mergeCells("A1:H1", format); //Set the height of the first row to 50.0(points) xlsx.setRowHeight(1, 50.0); //Set the width of the third column to 40.0(chars) //xlsx.setColumnWidth(3, 3, 40.0); //Set style for the row 11th. QXlsx::Format format1; format1.setFontBold(true); format1.setFontColor(QColor(Qt::blue)); format1.setFontSize(20); xlsx.write(11, 1, "Hello Row Style"); xlsx.write(11, 6, "Blue Color"); xlsx.setRowFormat(11, format1); xlsx.setRowHeight(11, 41); //Set style for the col [9th, 16th) QXlsx::Format format2; format2.setFontBold(true); format2.setFontColor(QColor(Qt::magenta)); for (int row=2; row<=16; row++) for (int col=1; col<=8; col++) xlsx.write(row, col, row+col); xlsx.setColumnWidth(9, 16, 5.0); xlsx.setColumnFormat(9, 16, format2); xlsx.save();
就可以看到如下的效果了:
0 0
- Qt下Excel报表生成的又一利器----QtXlsxWriter
- Qt之操作Excel(QtXlsxWriter)
- Qt之操作Excel(QtXlsxWriter)
- QtXlsxWriter---Qt操作excel文件
- Qt操作Excel文件 QtXlsxWriter的配置使用说明
- Qt Xlsx ( QtXlsxWriter ) qt读写excel文件库的windows安装使用
- Qt Xlsx ( QtXlsxWriter ) qt读写excel文件库的windows安装使用
- Qt下 编译和配置QtXlsxWriter (QtCreator下)
- Excel报表的生成[转贴]
- xfire--开发WEB SERVICE的又一利器
- 排名函数--SQLSERVER2005的又一编程利器
- .net关于企业Excel报表的生成
- .net关于企业Excel报表的生成
- net关于企业Excel报表的生成
- .net关于企业Excel报表的生成
- .net关于企业Excel报表的生成
- 自已写的excel报表生成
- jsp生成Excel报表的方法
- Android Debug Bridge
- OPENGL入门汇总
- 黑马程序员 Java面向对象——(网络编程)
- OWL Web本体语言 指南(中文版)
- IAP java
- Qt下Excel报表生成的又一利器----QtXlsxWriter
- @synthesize和@property详解
- 回文时间(山东理工OJ)
- Activity及Dialog的全透明(附android系统自带图标大全)
- 字符编解码的故事(ASCII,ANSI,Unicode,Utf-8)
- zookeeper3.4.5内存分配
- IOS 开发学习(1): 学习纲领以及Objective-C 基本语法学习
- javascript生成动态表格,并为每个单元格添加单击事件
- 转换编码