Skip to content

Commit 6b1adc6

Browse files
committed
add a example. ReadColor
1 parent f405ab3 commit 6b1adc6

File tree

4 files changed

+85
-0
lines changed

4 files changed

+85
-0
lines changed

ReadColor/ReadColor.pro

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# ReadColor.pro
2+
3+
TARGET = ReadColor
4+
TEMPLATE = app
5+
6+
QT += core
7+
8+
CONFIG += console
9+
CONFIG -= app_bundle
10+
11+
DEFINES += QT_DEPRECATED_WARNINGS
12+
13+
##########################################################################
14+
# NOTE: You can fix value of QXlsx path of source code.
15+
# QXLSX_PARENTPATH=./
16+
# QXLSX_HEADERPATH=./header/
17+
# QXLSX_SOURCEPATH=./source/
18+
include(../QXlsx/QXlsx.pri)
19+
20+
SOURCES += main.cpp
21+
22+
RESOURCES += color.qrc
23+

ReadColor/color.qrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<RCC>
2+
<qresource prefix="/">
3+
<file>color.xlsx</file>
4+
</qresource>
5+
</RCC>

ReadColor/color.xlsx

8.29 KB
Binary file not shown.

ReadColor/main.cpp

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// main.cpp
2+
3+
#include <QtGlobal>
4+
#include <QCoreApplication>
5+
#include <QtCore>
6+
#include <QVariant>
7+
#include <QDir>
8+
#include <QColor>
9+
#include <QDebug>
10+
11+
#include <iostream>
12+
using namespace std;
13+
14+
#include "xlsxdocument.h"
15+
#include "xlsxchartsheet.h"
16+
#include "xlsxcellrange.h"
17+
#include "xlsxchart.h"
18+
#include "xlsxrichstring.h"
19+
#include "xlsxworkbook.h"
20+
using namespace QXlsx;
21+
22+
void printColor(Cell* cell);
23+
24+
int main(int argc, char *argv[])
25+
{
26+
QCoreApplication app(argc, argv);
27+
28+
Document xlsxR(":/color.xlsx");
29+
if ( !xlsxR.load() )
30+
{
31+
return (-1);
32+
}
33+
34+
printColor( xlsxR.cellAt(1, 1) );
35+
printColor( xlsxR.cellAt(1, 2) );
36+
printColor( xlsxR.cellAt(2, 1) );
37+
printColor( xlsxR.cellAt(2, 2) );
38+
39+
return 0;
40+
}
41+
42+
void printColor(Cell* cell)
43+
{
44+
if ( NULL == cell )
45+
return;
46+
47+
QColor clrForeGround = cell->format().patternForegroundColor();
48+
QColor clrBackGround = cell->format().patternBackgroundColor();
49+
50+
if ( clrForeGround.isValid() &&
51+
clrBackGround.isValid() )
52+
{
53+
qDebug() << "[debug] color : " << clrForeGround << clrBackGround;
54+
}
55+
56+
57+
}

0 commit comments

Comments
 (0)