mirror of
https://github.com/QtExcel/QXlsx.git
synced 2025-01-30 05:02:52 +08:00
Supports old Qt5. Backward compatibility was considered.
This commit is contained in:
parent
7ec48fd1c4
commit
3a8512364a
9
.gitignore
vendored
9
.gitignore
vendored
@ -46,19 +46,16 @@ QXlsx/debug/*
|
||||
QXlsx/release/*
|
||||
*.-1
|
||||
*.pro.user
|
||||
build-QXlsx-Desktop_Qt_5_10_1_MinGW_32bit-Debug/
|
||||
build-TestExcel-Desktop_Qt_5_10_1_MinGW_32bit-Debug/
|
||||
build-QXlsx-Desktop_Qt_5_10_1_MinGW_32bit-Release/
|
||||
build-TestExcel-Desktop_Qt_5_10_1_MinGW_32bit-Release/
|
||||
build-Copycat-Desktop_Qt_5_11_1_MinGW_32bit-Debug/
|
||||
build-Copycat-Desktop_Qt_5_11_1_MinGW_32bit-Release/
|
||||
build-*/
|
||||
/build-*/*
|
||||
|
||||
# visual studio
|
||||
*.pdb
|
||||
*.filters
|
||||
*.user
|
||||
*.user.-1
|
||||
*.props
|
||||
*.filter
|
||||
|
||||
## Ignore Visual Studio temporary files, build results, and
|
||||
## files generated by popular Visual Studio add-ons.
|
||||
|
20
.travis.yml
20
.travis.yml
@ -9,19 +9,21 @@ sudo: require
|
||||
dist: xenial # Ubuntu Xenial 16.04, Trusty 14.04, Precise 12.04
|
||||
|
||||
before_install:
|
||||
# - sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa
|
||||
# - sudo apt-get update -qq
|
||||
- sudo add-apt-repository --yes ppa:ubuntu-sdk-team/ppa
|
||||
- sudo apt-get update -qq
|
||||
#- sudo add-apt-repository ppa:ubuntu-toolchain-r/test
|
||||
#- sudo apt update
|
||||
sudo add-apt-repository ppa:jonathonf/gcc-7.1
|
||||
sudo apt-get update
|
||||
# sudo add-apt-repository ppa:jonathonf/gcc-7.1
|
||||
# sudo apt-get update
|
||||
|
||||
# gcc 7
|
||||
- sudo apt-get install gcc-7 g++-7
|
||||
- sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7
|
||||
- sudo update-alternatives --config gcc
|
||||
- gcc --version
|
||||
- g++ --version
|
||||
# - sudo apt-get install gcc-7 g++-7
|
||||
# - sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-7
|
||||
# - sudo update-alternatives --config gcc
|
||||
|
||||
# check gcc version
|
||||
- gcc --version
|
||||
- g++ --version
|
||||
|
||||
# Qt
|
||||
- sudo apt-get install qtbase5-dev qtdeclarative5-dev libqt5webkit5-dev libsqlite3-dev
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include <QFont>
|
||||
#include <QBrush>
|
||||
#include <QDebug>
|
||||
#include <QTextCharFormat>
|
||||
|
||||
#include "XlsxTab.h"
|
||||
#include "xlsxcell.h"
|
||||
@ -158,25 +159,25 @@ bool XlsxTab::setSheet()
|
||||
Qt::BrushStyle qbs = Qt::NoBrush;
|
||||
switch(fp)
|
||||
{
|
||||
case Format::FillPattern::PatternNone : qbs = Qt::NoBrush; break;
|
||||
case Format::FillPattern::PatternSolid : qbs = Qt::SolidPattern; break;
|
||||
case Format::FillPattern::PatternMediumGray :
|
||||
case Format::FillPattern::PatternDarkGray :
|
||||
case Format::FillPattern::PatternLightGray :
|
||||
case Format::FillPattern::PatternDarkHorizontal :
|
||||
case Format::FillPattern::PatternDarkVertical :
|
||||
case Format::FillPattern::PatternDarkDown :
|
||||
case Format::FillPattern::PatternDarkUp :
|
||||
case Format::FillPattern::PatternDarkGrid :
|
||||
case Format::FillPattern::PatternDarkTrellis :
|
||||
case Format::FillPattern::PatternLightHorizontal :
|
||||
case Format::FillPattern::PatternLightVertical :
|
||||
case Format::FillPattern::PatternLightDown :
|
||||
case Format::FillPattern::PatternLightUp :
|
||||
case Format::FillPattern::PatternLightTrellis :
|
||||
case Format::FillPattern::PatternGray125 :
|
||||
case Format::FillPattern::PatternGray0625 :
|
||||
case Format::FillPattern::PatternLightGrid :
|
||||
case Format::PatternNone : qbs = Qt::NoBrush; break;
|
||||
case Format::PatternSolid : qbs = Qt::SolidPattern; break;
|
||||
case Format::PatternMediumGray :
|
||||
case Format::PatternDarkGray :
|
||||
case Format::PatternLightGray :
|
||||
case Format::PatternDarkHorizontal :
|
||||
case Format::PatternDarkVertical :
|
||||
case Format::PatternDarkDown :
|
||||
case Format::PatternDarkUp :
|
||||
case Format::PatternDarkGrid :
|
||||
case Format::PatternDarkTrellis :
|
||||
case Format::PatternLightHorizontal :
|
||||
case Format::PatternLightVertical :
|
||||
case Format::PatternLightDown :
|
||||
case Format::PatternLightUp :
|
||||
case Format::PatternLightTrellis :
|
||||
case Format::PatternGray125 :
|
||||
case Format::PatternGray0625 :
|
||||
case Format::PatternLightGrid :
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -194,23 +195,23 @@ bool XlsxTab::setSheet()
|
||||
Format::HorizontalAlignment ha = ptrCell->format().horizontalAlignment();
|
||||
switch(ha)
|
||||
{
|
||||
case Format::HorizontalAlignment::AlignHCenter :
|
||||
case Format::HorizontalAlignment::AlignHFill :
|
||||
case Format::HorizontalAlignment::AlignHMerge :
|
||||
case Format::HorizontalAlignment::AlignHDistributed :
|
||||
case Format::AlignHCenter :
|
||||
case Format::AlignHFill :
|
||||
case Format::AlignHMerge :
|
||||
case Format::AlignHDistributed :
|
||||
alignment = alignment | Qt::AlignHCenter;
|
||||
break;
|
||||
|
||||
case Format::HorizontalAlignment::AlignRight :
|
||||
case Format::AlignRight :
|
||||
alignment = alignment | Qt::AlignRight;
|
||||
break;
|
||||
|
||||
case Format::HorizontalAlignment::AlignHJustify :
|
||||
case Format::AlignHJustify :
|
||||
alignment = alignment | Qt::AlignJustify;
|
||||
break;
|
||||
|
||||
case Format::HorizontalAlignment::AlignLeft :
|
||||
case Format::HorizontalAlignment::AlignHGeneral :
|
||||
case Format::AlignLeft :
|
||||
case Format::AlignHGeneral :
|
||||
default:
|
||||
alignment = alignment | Qt::AlignLeft;
|
||||
break;
|
||||
@ -219,22 +220,23 @@ bool XlsxTab::setSheet()
|
||||
Format::VerticalAlignment va = ptrCell->format().verticalAlignment();
|
||||
switch(va)
|
||||
{
|
||||
case Format::VerticalAlignment::AlignTop :
|
||||
case Format::AlignTop :
|
||||
alignment = alignment | Qt::AlignTop;
|
||||
break;
|
||||
|
||||
case Format::VerticalAlignment::AlignVCenter :
|
||||
case Format::AlignVCenter :
|
||||
alignment = alignment | Qt::AlignVCenter;
|
||||
break;
|
||||
|
||||
case Format::VerticalAlignment::AlignBottom :
|
||||
case Format::AlignBottom :
|
||||
alignment = alignment | Qt::AlignBottom;
|
||||
break;
|
||||
|
||||
case Format::VerticalAlignment::AlignVJustify :
|
||||
case Format::VerticalAlignment::AlignVDistributed :
|
||||
case Format::AlignVJustify :
|
||||
case Format::AlignVDistributed :
|
||||
default:
|
||||
alignment = alignment | Qt::AlignBaseline;
|
||||
// alignment = alignment | (int)(Qt::AlignBaseline);
|
||||
alignment = alignment | QTextCharFormat::AlignBaseline;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifndef XLSXTAB_H
|
||||
#define XLSXTAB_H
|
||||
|
||||
#include <cstdio>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
@ -18,9 +20,9 @@ class XlsxTab : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit XlsxTab(QWidget* parent = nullptr,
|
||||
QXlsx::Document* ptrDoc = nullptr,
|
||||
QXlsx::AbstractSheet* ptrSheet = nullptr,
|
||||
explicit XlsxTab(QWidget* parent = NULL,
|
||||
QXlsx::Document* ptrDoc = NULL,
|
||||
QXlsx::AbstractSheet* ptrSheet = NULL,
|
||||
int SheetIndex = -1);
|
||||
virtual ~XlsxTab();
|
||||
|
||||
|
@ -4,6 +4,8 @@
|
||||
- Hello world example
|
||||
|
||||
```cpp
|
||||
// main.cpp
|
||||
|
||||
// [0] include QXlsx headers
|
||||
#include "xlsxdocument.h"
|
||||
#include "xlsxchartsheet.h"
|
||||
@ -40,7 +42,7 @@ int main(int argc, char *argv[])
|
||||
```
|
||||
|
||||
## TestExcel
|
||||
- Basic samples based on QtXlsx samples
|
||||
- :zap: Basic examples based on QtXlsx examples
|
||||
|
||||
## HelloAndroid : Android Example
|
||||
- See 'HelloAndroid' example using QML and native C++.
|
||||
@ -56,6 +58,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
## WebServer : WebServer Example
|
||||
- Load xlsx file and display on Web.
|
||||
- C++ 14 is required.
|
||||
- Connect to `http://127.0.0.1:3001`
|
||||
|
||||
![](markdown.data/webserver.png)
|
||||
|
@ -164,10 +164,11 @@ void Chart::setAxisTitle(Chart::ChartAxisPos pos, QString axisTitle)
|
||||
if ( axisTitle.isEmpty() )
|
||||
return;
|
||||
|
||||
if ( pos == Chart::ChartAxisPos::Left ) d->axisNames[ XlsxAxis::AxisPos::Left ] = axisTitle;
|
||||
else if ( pos == Chart::ChartAxisPos::Top ) d->axisNames[ XlsxAxis::AxisPos::Top ] = axisTitle;
|
||||
else if ( pos == Chart::ChartAxisPos::Right ) d->axisNames[ XlsxAxis::AxisPos::Right ] = axisTitle;
|
||||
else if ( pos == Chart::ChartAxisPos::Bottom ) d->axisNames[ XlsxAxis::AxisPos::Bottom ] = axisTitle;
|
||||
// dev24 : fixed for old compiler
|
||||
if ( pos == Chart::Left ) d->axisNames[ XlsxAxis::Left ] = axisTitle;
|
||||
else if ( pos == Chart::Top ) d->axisNames[ XlsxAxis::Top ] = axisTitle;
|
||||
else if ( pos == Chart::Right ) d->axisNames[ XlsxAxis::Right ] = axisTitle;
|
||||
else if ( pos == Chart::Bottom ) d->axisNames[ XlsxAxis::Bottom ] = axisTitle;
|
||||
else
|
||||
{
|
||||
// ??
|
||||
@ -429,9 +430,9 @@ void ChartPrivate::saveXmlBarChart(QXmlStreamWriter &writer) const
|
||||
|
||||
if ( axisList.isEmpty() )
|
||||
{
|
||||
//The order the axes??
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Cat, XlsxAxis::AxisPos::Bottom, 0, 1, axisNames[XlsxAxis::AxisPos::Bottom] )));
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Val, XlsxAxis::AxisPos::Left, 1, 0, axisNames[XlsxAxis::AxisPos::Left] )));
|
||||
// The order the axes??
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Cat, XlsxAxis::Bottom, 0, 1, axisNames[XlsxAxis::Bottom] )));
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Val, XlsxAxis::Left, 1, 0, axisNames[XlsxAxis::Left] )));
|
||||
}
|
||||
|
||||
//Note: Bar3D have 2~3 axes
|
||||
@ -459,10 +460,10 @@ void ChartPrivate::saveXmlLineChart(QXmlStreamWriter &writer) const
|
||||
|
||||
if (axisList.isEmpty())
|
||||
{
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Cat, XlsxAxis::AxisPos::Bottom, 0, 1, axisNames[XlsxAxis::AxisPos::Bottom] )));
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Val, XlsxAxis::AxisPos::Left, 1, 0, axisNames[XlsxAxis::AxisPos::Left] )));
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Cat, XlsxAxis::Bottom, 0, 1, axisNames[XlsxAxis::Bottom] )));
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Val, XlsxAxis::Left, 1, 0, axisNames[XlsxAxis::Left] )));
|
||||
if (chartType==Chart::CT_Line3D)
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Ser, XlsxAxis::AxisPos::Bottom, 2, 0)));
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Ser, XlsxAxis::Bottom, 2, 0)));
|
||||
}
|
||||
|
||||
Q_ASSERT((axisList.size()==2||chartType==Chart::CT_Line)|| (axisList.size()==3 && chartType==Chart::CT_Line3D));
|
||||
@ -488,8 +489,8 @@ void ChartPrivate::saveXmlScatterChart(QXmlStreamWriter &writer) const
|
||||
|
||||
if (axisList.isEmpty())
|
||||
{
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Val, XlsxAxis::AxisPos::Bottom, 0, 1, axisNames[XlsxAxis::AxisPos::Bottom] )));
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Val, XlsxAxis::AxisPos::Left, 1, 0, axisNames[XlsxAxis::AxisPos::Left] )));
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Val, XlsxAxis::Bottom, 0, 1, axisNames[XlsxAxis::Bottom] )));
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Val, XlsxAxis::Left, 1, 0, axisNames[XlsxAxis::Left] )));
|
||||
}
|
||||
|
||||
Q_ASSERT(axisList.size()==2);
|
||||
@ -516,8 +517,8 @@ void ChartPrivate::saveXmlAreaChart(QXmlStreamWriter &writer) const
|
||||
|
||||
if (axisList.isEmpty())
|
||||
{
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Cat, XlsxAxis::AxisPos::Bottom, 0, 1)));
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Val, XlsxAxis::AxisPos::Left, 1, 0)));
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Cat, XlsxAxis::Bottom, 0, 1)));
|
||||
const_cast<ChartPrivate*>(this)->axisList.append(QSharedPointer<XlsxAxis>(new XlsxAxis(XlsxAxis::T_Val, XlsxAxis::Left, 1, 0)));
|
||||
}
|
||||
|
||||
//Note: Area3D have 2~3 axes
|
||||
@ -619,15 +620,15 @@ bool ChartPrivate::loadXmlAxis(QXmlStreamReader &reader)
|
||||
QXmlStreamAttributes attrs = reader.attributes();
|
||||
QStringRef pos = attrs.value(QLatin1String("val"));
|
||||
if ( pos == QLatin1String("l") )
|
||||
axis->axisPos = XlsxAxis::AxisPos::Left;
|
||||
axis->axisPos = XlsxAxis::Left;
|
||||
else if ( pos == QLatin1String("r") )
|
||||
axis->axisPos = XlsxAxis::AxisPos::Right;
|
||||
axis->axisPos = XlsxAxis::Right;
|
||||
else if ( pos == QLatin1String("b") )
|
||||
axis->axisPos = XlsxAxis::AxisPos::Bottom;
|
||||
axis->axisPos = XlsxAxis::Bottom;
|
||||
else if ( pos == QLatin1String("t") )
|
||||
axis->axisPos = XlsxAxis::AxisPos::Top;
|
||||
axis->axisPos = XlsxAxis::Top;
|
||||
else
|
||||
axis->axisPos = XlsxAxis::AxisPos::None;
|
||||
axis->axisPos = XlsxAxis::None;
|
||||
}
|
||||
else if ( reader.name() == QLatin1String("axId") )
|
||||
{
|
||||
@ -657,20 +658,20 @@ void ChartPrivate::saveXmlAxes(QXmlStreamWriter &writer) const
|
||||
QString name;
|
||||
switch (axis->type)
|
||||
{
|
||||
case XlsxAxis::T_Cat: name = QStringLiteral("c:catAx"); break;
|
||||
case XlsxAxis::T_Val: name = QStringLiteral("c:valAx"); break;
|
||||
case XlsxAxis::T_Ser: name = QStringLiteral("c:serAx"); break;
|
||||
case XlsxAxis::T_Date: name = QStringLiteral("c:dateAx"); break;
|
||||
case XlsxAxis::T_Cat : name = QStringLiteral("c:catAx"); break;
|
||||
case XlsxAxis::T_Val : name = QStringLiteral("c:valAx"); break;
|
||||
case XlsxAxis::T_Ser : name = QStringLiteral("c:serAx"); break;
|
||||
case XlsxAxis::T_Date : name = QStringLiteral("c:dateAx"); break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
QString pos;
|
||||
switch (axis->axisPos)
|
||||
{
|
||||
case XlsxAxis::AxisPos::Top: pos = QStringLiteral("t"); break;
|
||||
case XlsxAxis::AxisPos::Bottom: pos = QStringLiteral("b"); break;
|
||||
case XlsxAxis::AxisPos::Left: pos = QStringLiteral("l"); break;
|
||||
case XlsxAxis::AxisPos::Right: pos = QStringLiteral("r"); break;
|
||||
case XlsxAxis::Top : pos = QStringLiteral("t"); break;
|
||||
case XlsxAxis::Bottom : pos = QStringLiteral("b"); break;
|
||||
case XlsxAxis::Left : pos = QStringLiteral("l"); break;
|
||||
case XlsxAxis::Right : pos = QStringLiteral("r"); break;
|
||||
default: break; // ??
|
||||
}
|
||||
|
||||
|
@ -394,8 +394,15 @@ void DrawingAnchor::loadXmlObjectShape(QXmlStreamReader &reader)
|
||||
extTA = loadXmlExt(reader);
|
||||
hasoffext=false;
|
||||
}else if(reader.name() == QLatin1String("blipFill")){
|
||||
rotWithShapeTA= reader.attributes().value(QLatin1String("rotWithShape")).toInt();
|
||||
dpiTA= reader.attributes().value(QLatin1String("dpi")).toInt();
|
||||
|
||||
// dev24 : fixed for old Qt 5
|
||||
|
||||
rotWithShapeTA = reader.attributes().value(QLatin1String("rotWithShape")).toString().toInt();
|
||||
dpiTA = reader.attributes().value(QLatin1String("dpi")).toString().toInt();
|
||||
|
||||
// rotWithShapeTA = reader.attributes().value(QLatin1String("rotWithShape")).toInt();
|
||||
// dpiTA = reader.attributes().value(QLatin1String("dpi")).toInt();
|
||||
|
||||
}else if(reader.name() == QLatin1String("cNvPr")){
|
||||
xsp_cNvPR_name= reader.attributes().value(QLatin1String("name")).toString();
|
||||
xsp_cNvPR_id= reader.attributes().value(QLatin1String("id")).toString();
|
||||
|
@ -147,8 +147,8 @@ void sat_calc::generate_report()
|
||||
Chart * Crom = output.insertChart( 3, 5, QSize(600, 500) );
|
||||
Crom->setChartType( Chart::CT_Scatter );
|
||||
Crom->addSeries( CellRange(chrom_data_array) );
|
||||
Crom->setAxisTitle( Chart::ChartAxisPos::Left, QString("left title") ); // dev22
|
||||
Crom->setAxisTitle( Chart::ChartAxisPos::Bottom, QString("bottom title") ); // dev22
|
||||
Crom->setAxisTitle( Chart::Left, QString("left title") ); // dev24
|
||||
Crom->setAxisTitle( Chart::Bottom, QString("bottom title") ); // dev24
|
||||
|
||||
qDebug() << "[debug] chrom_data_array : " << chrom_data_array;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user