1
0
mirror of https://github.com/QtExcel/QXlsx.git synced 2025-01-16 04:42:53 +08:00

add a example. ReadColor

This commit is contained in:
Jay Two 2020-02-07 20:55:00 +09:00
parent f405ab35d0
commit 6b1adc6a35
4 changed files with 85 additions and 0 deletions

23
ReadColor/ReadColor.pro Normal file
View File

@ -0,0 +1,23 @@
# ReadColor.pro
TARGET = ReadColor
TEMPLATE = app
QT += core
CONFIG += console
CONFIG -= app_bundle
DEFINES += QT_DEPRECATED_WARNINGS
##########################################################################
# NOTE: You can fix value of QXlsx path of source code.
# QXLSX_PARENTPATH=./
# QXLSX_HEADERPATH=./header/
# QXLSX_SOURCEPATH=./source/
include(../QXlsx/QXlsx.pri)
SOURCES += main.cpp
RESOURCES += color.qrc

5
ReadColor/color.qrc Normal file
View File

@ -0,0 +1,5 @@
<RCC>
<qresource prefix="/">
<file>color.xlsx</file>
</qresource>
</RCC>

BIN
ReadColor/color.xlsx Normal file

Binary file not shown.

57
ReadColor/main.cpp Normal file
View File

@ -0,0 +1,57 @@
// main.cpp
#include <QtGlobal>
#include <QCoreApplication>
#include <QtCore>
#include <QVariant>
#include <QDir>
#include <QColor>
#include <QDebug>
#include <iostream>
using namespace std;
#include "xlsxdocument.h"
#include "xlsxchartsheet.h"
#include "xlsxcellrange.h"
#include "xlsxchart.h"
#include "xlsxrichstring.h"
#include "xlsxworkbook.h"
using namespace QXlsx;
void printColor(Cell* cell);
int main(int argc, char *argv[])
{
QCoreApplication app(argc, argv);
Document xlsxR(":/color.xlsx");
if ( !xlsxR.load() )
{
return (-1);
}
printColor( xlsxR.cellAt(1, 1) );
printColor( xlsxR.cellAt(1, 2) );
printColor( xlsxR.cellAt(2, 1) );
printColor( xlsxR.cellAt(2, 2) );
return 0;
}
void printColor(Cell* cell)
{
if ( NULL == cell )
return;
QColor clrForeGround = cell->format().patternForegroundColor();
QColor clrBackGround = cell->format().patternBackgroundColor();
if ( clrForeGround.isValid() &&
clrBackGround.isValid() )
{
qDebug() << "[debug] color : " << clrForeGround << clrBackGround;
}
}