QXlsx读写excel
2016-06-08 14:21
351 查看
读:
QXlsx::Document xlsx(_filePath);
int intRowStart = xlsx.dimension().firstRow();
int intColStart = xlsx.dimension().firstColumn();
QStringList postHeaderList;
for (int row = intRowStart; row <= xlsx.dimension().rowCount(); row++) {
for (int column = intColStart; column < xlsx.dimension().columnCount(); column++) {
QXlsx::Cell *cell = xlsx.cellAt(xlsx.dimension().firstRow(), j); //获取单元格
if (cell == NULL) {
postHeaderList.append("");
} else {
postHeaderList.append(cell->value().toString());
}
}
}写:
int cellRow = 1;
int cellColumn = 1;
QXlsx::Format format;
format.setHorizontalAlignment(QXlsx::Format::AlignHCenter);
format.setVerticalAlignment(QXlsx::Format::AlignVCenter);
format.setPatternBackgroundColor("#cccccc");
QXlsx::CellReference cellReferenceTop(cellRow, cellColumn);
xlsx.write(cellReferenceTop, "hello", format);合并:
xlsx.mergeCells(QXlsx::CellRange(romLeftTop,columnLeftTop, rowRightBottom, columnRightBottom));设置列宽:
xlsx.setColumnWidth(cellColumn, colWidthCm); //xls列宽单位为cm
相关文章推荐
- QT学习 第一章:基本对话框
- 使用Shiboken为C++和Qt库创建Python绑定
- Qt 5.6更新至RC版,最终版本近在咫尺
- Qt定时器和随机数详解
- Qt实现图片移动实例(图文教程)
- Qt for Android开发实例教程
- QModelIndex/Role/Model介紹<二>
- Qt Model/View/Delegate浅谈 - QAbstractListModel
- Qt Model/View/Delegate浅谈 - roleNames()
- QT历程(一):与CryptoJs对应的AES加密
- 基于PyQt5的快速开发框架QFramer
- OSX下安装PyQt
- ok6410开发板移植DirectFB手记
- 【笔记】给Qt内嵌一个Chrome吧
- 【算法】最短路径之A*搜索
- qt入门必备
- 在 Qt4 中使用 C++11
- Hello Word ~ v0.2.2 背单词软件发布 -- By WHYPRO
- ubuntu下opencv和qt的安装配置
- linux下opengl的安装(with qt)