mirror of
https://github.com/QtExcel/QXlsx.git
synced 2025-01-30 05:02:52 +08:00
change processing of datatype
This commit is contained in:
parent
0a26c175b1
commit
ce5793c497
@ -1,8 +1,5 @@
|
||||
#
|
||||
# Copycat.pro
|
||||
#
|
||||
# QXlsx, MIT License, https://github.com/QtExcel/QXlsx
|
||||
#
|
||||
# QXlsx https://github.com/QtExcel/QXlsx
|
||||
|
||||
TARGET = Copycat
|
||||
TEMPLATE = app
|
||||
|
@ -95,7 +95,7 @@ bool XlsxTab::setSheet()
|
||||
CellLocation cl = clList.at(ic);
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// First cell of tableWidget is 0.
|
||||
// First cell index of tableWidget is 0.
|
||||
// But first cell of Qxlsx document is 1.
|
||||
int row = cl.row - 1;
|
||||
int col = cl.col - 1;
|
||||
@ -117,45 +117,9 @@ bool XlsxTab::setSheet()
|
||||
QString str;
|
||||
Cell::CellType cType = cl.cell->cellType();
|
||||
|
||||
// [dev54]
|
||||
if ( cType == Cell::DateType )
|
||||
{
|
||||
QString strValue;
|
||||
QString strDate;
|
||||
QString strTime;
|
||||
bool isSetTime = false;
|
||||
// qDebug() << "(r,c) = " << cl.row << cl.col << var.toString() ;
|
||||
|
||||
QDateTime datetimeValue = var.toDateTime();
|
||||
|
||||
QTime timeValue = datetimeValue.time();
|
||||
if ( timeValue.isValid() )
|
||||
{
|
||||
strTime = timeValue.toString();
|
||||
|
||||
strValue.append( strTime );
|
||||
|
||||
isSetTime = true;
|
||||
}
|
||||
|
||||
QDate dateValue = datetimeValue.date();
|
||||
if ( ! dateValue.isNull() )
|
||||
{
|
||||
strDate = dateValue.toString();
|
||||
|
||||
if (isSetTime)
|
||||
strValue.append( " " );
|
||||
|
||||
strValue.append( strDate );
|
||||
}
|
||||
|
||||
|
||||
str = strValue;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
str = var.toString();
|
||||
}
|
||||
str = var.toString();
|
||||
|
||||
////////////////////////////////////////////////////////////////////
|
||||
// set text
|
||||
|
@ -93,7 +93,8 @@ $${QXLSX_HEADERPATH}xlsxworksheet.h \
|
||||
$${QXLSX_HEADERPATH}xlsxworksheet_p.h \
|
||||
$${QXLSX_HEADERPATH}xlsxzipreader_p.h \
|
||||
$${QXLSX_HEADERPATH}xlsxzipwriter_p.h \
|
||||
$${QXLSX_HEADERPATH}xlsxcelllocation.h
|
||||
$${QXLSX_HEADERPATH}xlsxcelllocation.h \
|
||||
$${QXLSX_HEADERPATH}xlsxdatetype.h
|
||||
|
||||
SOURCES += \
|
||||
$${QXLSX_SOURCEPATH}xlsxabstractooxmlfile.cpp \
|
||||
@ -127,7 +128,8 @@ $${QXLSX_SOURCEPATH}xlsxworkbook.cpp \
|
||||
$${QXLSX_SOURCEPATH}xlsxworksheet.cpp \
|
||||
$${QXLSX_SOURCEPATH}xlsxzipreader.cpp \
|
||||
$${QXLSX_SOURCEPATH}xlsxzipwriter.cpp \
|
||||
$${QXLSX_SOURCEPATH}xlsxcelllocation.cpp
|
||||
$${QXLSX_SOURCEPATH}xlsxcelllocation.cpp \
|
||||
$${QXLSX_SOURCEPATH}xlsxdatetype.cpp
|
||||
|
||||
|
||||
######################################################################
|
||||
|
@ -3,9 +3,6 @@
|
||||
#ifndef QXLSX_XLSXABSTRACTOOXMLFILE_H
|
||||
#define QXLSX_XLSXABSTRACTOOXMLFILE_H
|
||||
|
||||
#include <QIODevice>
|
||||
#include <QByteArray>
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
@ -3,11 +3,11 @@
|
||||
#ifndef XLSXOOXMLFILE_P_H
|
||||
#define XLSXOOXMLFILE_P_H
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
|
||||
#include "xlsxabstractooxmlfile.h"
|
||||
#include "xlsxrelationships_p.h"
|
||||
|
||||
#include <QString>
|
||||
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
class AbstractOOXmlFilePrivate
|
||||
@ -15,11 +15,11 @@ class AbstractOOXmlFilePrivate
|
||||
Q_DECLARE_PUBLIC(AbstractOOXmlFile)
|
||||
|
||||
public:
|
||||
AbstractOOXmlFilePrivate(AbstractOOXmlFile *q, AbstractOOXmlFile::CreateFlag flag);
|
||||
AbstractOOXmlFilePrivate(AbstractOOXmlFile* q, AbstractOOXmlFile::CreateFlag flag);
|
||||
virtual ~AbstractOOXmlFilePrivate();
|
||||
|
||||
public:
|
||||
QString filePathInPackage;//such as "xl/worksheets/sheet1.xml"
|
||||
QString filePathInPackage; //such as "xl/worksheets/sheet1.xml"
|
||||
|
||||
Relationships *relationships;
|
||||
AbstractOOXmlFile::CreateFlag flag;
|
||||
|
@ -3,12 +3,7 @@
|
||||
#ifndef XLSXABSTRACTSHEET_H
|
||||
#define XLSXABSTRACTSHEET_H
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
#include "xlsxabstractooxmlfile.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
@ -1,46 +1,14 @@
|
||||
/****************************************************************************
|
||||
** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
|
||||
** All right reserved.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining
|
||||
** a copy of this software and associated documentation files (the
|
||||
** "Software"), to deal in the Software without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Software, and to
|
||||
** permit persons to whom the Software is furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be
|
||||
** included in all copies or substantial portions of the Software.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
**
|
||||
****************************************************************************/
|
||||
//
|
||||
|
||||
#ifndef XLSXABSTRACTSHEET_P_H
|
||||
#define XLSXABSTRACTSHEET_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt Xlsx API. It exists for the convenience
|
||||
// of the Qt Xlsx. This header file may change from
|
||||
// version to version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QString>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
|
||||
#include "xlsxabstractsheet.h"
|
||||
#include "xlsxabstractooxmlfile_p.h"
|
||||
|
||||
@ -63,4 +31,5 @@ public:
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
#endif // XLSXABSTRACTSHEET_P_H
|
||||
|
@ -6,7 +6,12 @@
|
||||
#include <cstdio>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <QDate>
|
||||
#include <QDateTime>
|
||||
#include <QTime>
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
#include "xlsxformat.h"
|
||||
@ -62,7 +67,8 @@ public:
|
||||
CellFormula formula() const;
|
||||
|
||||
bool isDateTime() const;
|
||||
QDateTime dateTime() const;
|
||||
// QDateTime dateTime() const;
|
||||
QVariant dateTime() const;
|
||||
|
||||
bool isRichString() const;
|
||||
|
||||
|
@ -4,6 +4,7 @@
|
||||
#define QXLSX_XLSXCELLFORMULA_H
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
|
||||
#include <QExplicitlySharedDataPointer>
|
||||
|
||||
class QXmlStreamWriter;
|
||||
|
@ -1,41 +1,8 @@
|
||||
/****************************************************************************
|
||||
** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
|
||||
** All right reserved.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining
|
||||
** a copy of this software and associated documentation files (the
|
||||
** "Software"), to deal in the Software without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Software, and to
|
||||
** permit persons to whom the Software is furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be
|
||||
** included in all copies or substantial portions of the Software.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
**
|
||||
****************************************************************************/
|
||||
//
|
||||
|
||||
#ifndef XLSXCELLFORMULA_P_H
|
||||
#define XLSXCELLFORMULA_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt Xlsx API. It exists for the convenience
|
||||
// of the Qt Xlsx. This header file may change from
|
||||
// version to version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
#include "xlsxcellformula.h"
|
||||
#include "xlsxcellrange.h"
|
||||
|
@ -1,14 +1,5 @@
|
||||
//--------------------------------------------------------------------
|
||||
//
|
||||
// QXlsx
|
||||
// MIT License
|
||||
// https://github.com/j2doll/QXlsx
|
||||
//
|
||||
// QtXlsx
|
||||
// https://github.com/dbzhang800/QtXlsxWriter
|
||||
// http://qtxlsx.debao.me/
|
||||
// MIT License
|
||||
//
|
||||
|
||||
#ifndef CELL_LOCATION_H
|
||||
#define CELL_LOCATION_H
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
// xlsxcellrange.h
|
||||
|
||||
#ifndef QXLSX_XLSXCELLRANGE_H
|
||||
#define QXLSX_XLSXCELLRANGE_H
|
||||
|
||||
|
@ -37,18 +37,19 @@
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
#include <QVariant>
|
||||
#include <QColor>
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
|
||||
class QXmlStreamWriter;
|
||||
class QXmlStreamReader;
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
class Styles;
|
||||
|
||||
class XlsxColor
|
||||
class XlsxColor
|
||||
{
|
||||
public:
|
||||
explicit XlsxColor(const QColor &color = QColor());
|
||||
@ -85,7 +86,7 @@ private:
|
||||
QDebug operator<<(QDebug dbg, const XlsxColor &c);
|
||||
#endif
|
||||
|
||||
} // namespace QXlsx
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
Q_DECLARE_METATYPE(QXlsx::XlsxColor)
|
||||
|
||||
|
48
QXlsx/header/xlsxdatetype.h
Normal file
48
QXlsx/header/xlsxdatetype.h
Normal file
@ -0,0 +1,48 @@
|
||||
// xlsxdatetype.h
|
||||
|
||||
#ifndef QXLSX_XLSXDATETYPE_H
|
||||
#define QXLSX_XLSXDATETYPE_H
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QDateTime>
|
||||
#include <QDate>
|
||||
#include <QTime>
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
class DateType
|
||||
{
|
||||
public:
|
||||
DateType();
|
||||
/*
|
||||
DateType(bool is1904 = false);
|
||||
DateType(double d, bool is1904 = false);
|
||||
DateType(QDateTime qdt, bool is1904 = false);
|
||||
DateType(QDate qd, bool is1904 = false);
|
||||
DateType(QTime qt, bool is1904 = false);
|
||||
public:
|
||||
enum currentDateType { DateAndTimeType, OnlyDateType, OnlyTimeType };
|
||||
public:
|
||||
currentDateType getType();
|
||||
bool getValue(QDateTime* pQdt);
|
||||
bool getValue(QDate* pQd);
|
||||
bool getValue(QTime* pQt);
|
||||
bool getValue(double* pD);
|
||||
|
||||
protected:
|
||||
|
||||
protected:
|
||||
bool isSet;
|
||||
double dValue;
|
||||
bool is1904Type;
|
||||
currentDateType dType;
|
||||
*/
|
||||
};
|
||||
|
||||
QT_END_NAMESPACE_XLSX
|
||||
#endif
|
@ -45,7 +45,7 @@
|
||||
|
||||
class QIODevice;
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
class DocPropsApp : public AbstractOOXmlFile
|
||||
{
|
||||
@ -68,5 +68,6 @@ private:
|
||||
QMap<QString, QString> m_properties;
|
||||
};
|
||||
|
||||
}
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
#endif // XLSXDOCPROPSAPP_H
|
||||
|
@ -38,14 +38,15 @@
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
#include "xlsxabstractooxmlfile.h"
|
||||
|
||||
#include <QMap>
|
||||
#include <QStringList>
|
||||
|
||||
class QIODevice;
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
class DocPropsCore : public AbstractOOXmlFile
|
||||
class DocPropsCore : public AbstractOOXmlFile
|
||||
{
|
||||
public:
|
||||
explicit DocPropsCore(CreateFlag flag);
|
||||
@ -61,5 +62,6 @@ private:
|
||||
QMap<QString, QString> m_properties;
|
||||
};
|
||||
|
||||
}
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
#endif // XLSXDOCPROPSCORE_H
|
||||
|
@ -23,13 +23,15 @@
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QMap>
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
#include "xlsxdocument.h"
|
||||
#include "xlsxworkbook.h"
|
||||
#include "xlsxcontenttypes_p.h"
|
||||
|
||||
#include <QMap>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
class DocumentPrivate
|
||||
{
|
||||
@ -51,6 +53,6 @@ public:
|
||||
bool isLoad;
|
||||
};
|
||||
|
||||
}
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
#endif // XLSXDOCUMENT_P_H
|
||||
|
@ -37,17 +37,18 @@
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "xlsxrelationships_p.h"
|
||||
#include "xlsxabstractooxmlfile.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#include "xlsxrelationships_p.h"
|
||||
#include "xlsxabstractooxmlfile.h"
|
||||
|
||||
class QIODevice;
|
||||
class QXmlStreamWriter;
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
class DrawingAnchor;
|
||||
class Workbook;
|
||||
@ -67,6 +68,6 @@ public:
|
||||
QList<DrawingAnchor *> anchors;
|
||||
};
|
||||
|
||||
} // namespace QXlsx
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
#endif // QXLSX_DRAWING_H
|
||||
|
@ -32,11 +32,10 @@
|
||||
#include <QSize>
|
||||
#include <QString>
|
||||
#include <QSharedPointer>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
class QXmlStreamReader;
|
||||
class QXmlStreamWriter;
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
class Drawing;
|
||||
class MediaFile;
|
||||
@ -171,6 +170,6 @@ public:
|
||||
void saveToXml(QXmlStreamWriter &writer) const;
|
||||
};
|
||||
|
||||
} // namespace QXlsx
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
#endif // QXLSX_XLSXDRAWINGANCHOR_P_H
|
||||
|
@ -1,47 +1,14 @@
|
||||
/****************************************************************************
|
||||
** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
|
||||
** All right reserved.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining
|
||||
** a copy of this software and associated documentation files (the
|
||||
** "Software"), to deal in the Software without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Software, and to
|
||||
** permit persons to whom the Software is furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be
|
||||
** included in all copies or substantial portions of the Software.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
**
|
||||
****************************************************************************/
|
||||
//
|
||||
#ifndef XLSXFORMAT_P_H
|
||||
#define XLSXFORMAT_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt Xlsx API. It exists for the convenience
|
||||
// of the Qt Xlsx. This header file may change from
|
||||
// version to version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "xlsxformat.h"
|
||||
|
||||
#include <QSharedData>
|
||||
#include <QMap>
|
||||
#include <QSet>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
class FormatPrivate : public QSharedData
|
||||
{
|
||||
@ -156,6 +123,7 @@ public:
|
||||
QMap<int, QVariant> properties;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif // XLSXFORMAT_P_H
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
#endif
|
||||
|
@ -1,17 +1,25 @@
|
||||
// xlsxglobal.h
|
||||
// QXlsx // MIT License // https://github.com/j2doll/QXlsx
|
||||
// QtXlsx // MIT License // https://github.com/dbzhang800/QtXlsxWriter // http://qtxlsx.debao.me/
|
||||
|
||||
#ifndef XLSXGLOBAL_H
|
||||
#define XLSXGLOBAL_H
|
||||
|
||||
#include <cstdio>
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QVariant>
|
||||
#include <QIODevice>
|
||||
#include <QByteArray>
|
||||
#include <QStringList>
|
||||
#include <QSharedPointer>
|
||||
|
||||
#define QT_BEGIN_NAMESPACE_XLSX namespace QXlsx {
|
||||
|
||||
#define QT_END_NAMESPACE_XLSX }
|
||||
|
||||
#define QXLSX_USE_NAMESPACE using namespace QXlsx;
|
||||
|
||||
|
||||
#endif // XLSXGLOBAL_H
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include <QString>
|
||||
#include <QByteArray>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
class MediaFile
|
||||
{
|
||||
@ -75,6 +75,6 @@ private:
|
||||
QByteArray m_hashKey;
|
||||
};
|
||||
|
||||
} // namespace QXlsx
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
#endif // QXLSX_XLSXMEDIAFILE_H
|
||||
|
@ -38,7 +38,7 @@
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
class NumFormatParser
|
||||
{
|
||||
@ -46,6 +46,6 @@ public:
|
||||
static bool isDateTime(const QString &formatCode);
|
||||
};
|
||||
|
||||
} // namespace QXlsx
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
#endif // QXLSX_NUMFORMATPARSER_H
|
||||
|
@ -37,11 +37,12 @@
|
||||
//
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
class QIODevice;
|
||||
#include <QIODevice>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
struct XlsxRelationship
|
||||
{
|
||||
@ -83,5 +84,6 @@ private:
|
||||
QList<XlsxRelationship> m_relationships;
|
||||
};
|
||||
|
||||
}
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
#endif // XLSXRELATIONSHIPS_H
|
||||
|
@ -36,18 +36,18 @@
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
#include "xlsxrichstring.h"
|
||||
#include "xlsxabstractooxmlfile.h"
|
||||
#include <QHash>
|
||||
#include <QStringList>
|
||||
#include <QSharedPointer>
|
||||
#include <QIODevice>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QXmlStreamWriter>
|
||||
|
||||
class QIODevice;
|
||||
class QXmlStreamReader;
|
||||
class QXmlStreamWriter;
|
||||
#include "xlsxglobal.h"
|
||||
#include "xlsxrichstring.h"
|
||||
#include "xlsxabstractooxmlfile.h"
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
class XlsxSharedStringInfo
|
||||
{
|
||||
@ -94,5 +94,6 @@ private:
|
||||
int m_stringCount;
|
||||
};
|
||||
|
||||
}
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
#endif // XLSXSHAREDSTRINGS_H
|
||||
|
@ -38,9 +38,9 @@
|
||||
#include "xlsxabstractooxmlfile.h"
|
||||
|
||||
#include <QString>
|
||||
class QIODevice;
|
||||
#include <QIODevice>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
class SimpleOOXmlFile : public AbstractOOXmlFile
|
||||
{
|
||||
@ -55,5 +55,6 @@ public:
|
||||
QByteArray xmlData;
|
||||
};
|
||||
|
||||
}
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
#endif // XLSXSIMPLEOOXMLFILE_H
|
||||
|
@ -36,22 +36,23 @@
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
#include "xlsxformat.h"
|
||||
#include "xlsxabstractooxmlfile.h"
|
||||
#include <QSharedPointer>
|
||||
#include <QHash>
|
||||
#include <QList>
|
||||
#include <QMap>
|
||||
#include <QStringList>
|
||||
#include <QVector>
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QIODevice>
|
||||
|
||||
class QXmlStreamWriter;
|
||||
class QXmlStreamReader;
|
||||
class QIODevice;
|
||||
class StylesTest;
|
||||
// class StylesTest;
|
||||
|
||||
namespace QXlsx {
|
||||
#include "xlsxglobal.h"
|
||||
#include "xlsxformat.h"
|
||||
#include "xlsxabstractooxmlfile.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
class Format;
|
||||
class XlsxColor;
|
||||
@ -81,7 +82,7 @@ public:
|
||||
|
||||
private:
|
||||
friend class Format;
|
||||
friend class ::StylesTest;
|
||||
// friend class ::StylesTest;
|
||||
|
||||
void fixNumFmt(const Format &format);
|
||||
|
||||
@ -137,5 +138,6 @@ private:
|
||||
bool m_emptyFormatAdded;
|
||||
};
|
||||
|
||||
}
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
#endif // XLSXSTYLES_H
|
||||
|
@ -38,9 +38,9 @@
|
||||
#include "xlsxabstractooxmlfile.h"
|
||||
|
||||
#include <QString>
|
||||
class QIODevice;
|
||||
#include <QIODevice>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
class Theme : public AbstractOOXmlFile
|
||||
{
|
||||
@ -55,5 +55,6 @@ public:
|
||||
QByteArray xmlData;
|
||||
};
|
||||
|
||||
}
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
#endif // XLSXTHEME_H
|
||||
|
@ -37,12 +37,18 @@
|
||||
//
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
class QPoint;
|
||||
class QString;
|
||||
class QStringList;
|
||||
class QColor;
|
||||
class QDateTime;
|
||||
class QTime;
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QObject>
|
||||
#include <QString>
|
||||
#include <QPoint>
|
||||
#include <QString>
|
||||
#include <QStringList>
|
||||
#include <QColor>
|
||||
#include <QDateTime>
|
||||
#include <QDate>
|
||||
#include <QTime>
|
||||
#include <QVariant>
|
||||
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
@ -54,7 +60,7 @@ QStringList splitPath(const QString &path);
|
||||
QString getRelFilePath(const QString &filePath);
|
||||
|
||||
double datetimeToNumber(const QDateTime &dt, bool is1904=false);
|
||||
QDateTime datetimeFromNumber(double num, bool is1904=false);
|
||||
QVariant datetimeFromNumber(double num, bool is1904=false);
|
||||
double timeToNumber(const QTime &t);
|
||||
|
||||
QString createSafeSheetName(const QString &nameProposal);
|
||||
|
@ -1,41 +1,8 @@
|
||||
/****************************************************************************
|
||||
** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
|
||||
** All right reserved.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining
|
||||
** a copy of this software and associated documentation files (the
|
||||
** "Software"), to deal in the Software without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Software, and to
|
||||
** permit persons to whom the Software is furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be
|
||||
** included in all copies or substantial portions of the Software.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
**
|
||||
****************************************************************************/
|
||||
//
|
||||
|
||||
#ifndef XLSXWORKBOOK_P_H
|
||||
#define XLSXWORKBOOK_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
// -------------
|
||||
//
|
||||
// This file is not part of the Qt Xlsx API. It exists for the convenience
|
||||
// of the Qt Xlsx. This header file may change from
|
||||
// version to version without notice, or even be removed.
|
||||
//
|
||||
// We mean it.
|
||||
//
|
||||
|
||||
#include "xlsxworkbook.h"
|
||||
#include "xlsxabstractooxmlfile_p.h"
|
||||
#include "xlsxtheme_p.h"
|
||||
@ -46,7 +13,7 @@
|
||||
#include <QPair>
|
||||
#include <QStringList>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
struct XlsxDefineNameData
|
||||
{
|
||||
@ -102,6 +69,6 @@ public:
|
||||
int last_sheet_id;
|
||||
};
|
||||
|
||||
}
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
#endif // XLSXWORKBOOK_P_H
|
||||
|
@ -137,16 +137,30 @@ struct XlsxRowInfo
|
||||
|
||||
struct XlsxColumnInfo
|
||||
{
|
||||
XlsxColumnInfo(int firstColumn=0, int lastColumn=1, double width=0, const Format &format=Format(), bool hidden=false) :
|
||||
firstColumn(firstColumn), lastColumn(lastColumn), customWidth(false), width(width), format(format), hidden(hidden)
|
||||
, outlineLevel(0), collapsed(false)
|
||||
XlsxColumnInfo( int firstColumn, // = 0,
|
||||
int lastColumn, // = 1,
|
||||
bool isSetWidth,
|
||||
double width = 0,
|
||||
const Format &format = Format(),
|
||||
bool hidden = false)
|
||||
: firstColumn(firstColumn),
|
||||
lastColumn(lastColumn),
|
||||
customWidth(false),
|
||||
isSetWidth(isSetWidth),
|
||||
width(width),
|
||||
format(format),
|
||||
hidden(hidden),
|
||||
outlineLevel(0),
|
||||
collapsed(false)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
int firstColumn;
|
||||
int lastColumn;
|
||||
bool customWidth;
|
||||
double width;
|
||||
double width;
|
||||
bool isSetWidth;
|
||||
Format format;
|
||||
bool hidden;
|
||||
int outlineLevel;
|
||||
|
@ -38,15 +38,18 @@
|
||||
//
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
|
||||
#include <QScopedPointer>
|
||||
#include <QStringList>
|
||||
#if QT_VERSION >= 0x050600
|
||||
#include <QVector>
|
||||
#endif
|
||||
class QZipReader;
|
||||
class QIODevice;
|
||||
#include <QIODevice>
|
||||
|
||||
namespace QXlsx {
|
||||
#if QT_VERSION >= 0x050600
|
||||
#include <QVector>
|
||||
#endif
|
||||
|
||||
class QZipReader;
|
||||
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
class ZipReader
|
||||
{
|
||||
@ -65,6 +68,6 @@ private:
|
||||
QStringList m_filePaths;
|
||||
};
|
||||
|
||||
} // namespace QXlsx
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
#endif // QXLSX_XLSXZIPREADER_P_H
|
||||
|
@ -37,10 +37,13 @@
|
||||
//
|
||||
|
||||
#include <QString>
|
||||
class QIODevice;
|
||||
#include <QIODevice>
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
|
||||
class QZipWriter;
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
class ZipWriter
|
||||
{
|
||||
@ -58,6 +61,6 @@ private:
|
||||
QZipWriter *m_writer;
|
||||
};
|
||||
|
||||
} // namespace QXlsx
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
||||
#endif // QXLSX_ZIPWRITER_H
|
||||
|
@ -1,27 +1,4 @@
|
||||
/****************************************************************************
|
||||
** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
|
||||
** All right reserved.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining
|
||||
** a copy of this software and associated documentation files (the
|
||||
** "Software"), to deal in the Software without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Software, and to
|
||||
** permit persons to whom the Software is furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be
|
||||
** included in all copies or substantial portions of the Software.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
**
|
||||
****************************************************************************/
|
||||
//
|
||||
|
||||
#include "xlsxabstractooxmlfile.h"
|
||||
#include "xlsxabstractooxmlfile_p.h"
|
||||
@ -32,7 +9,7 @@
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
AbstractOOXmlFilePrivate::AbstractOOXmlFilePrivate(AbstractOOXmlFile *q, AbstractOOXmlFile::CreateFlag flag=AbstractOOXmlFile::F_NewFromScratch)
|
||||
:relationships(new Relationships), flag(flag), q_ptr(q)
|
||||
: relationships(new Relationships), flag(flag), q_ptr(q)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -119,64 +119,87 @@ QVariant Cell::readValue() const
|
||||
|
||||
if (isDateTime())
|
||||
{
|
||||
QDateTime dt = dateTime();
|
||||
ret = dt;
|
||||
QVariant vDT = dateTime();
|
||||
if ( vDT.isNull() )
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
if ( vDT.type() == QVariant::DateTime )
|
||||
{
|
||||
ret = vDT;
|
||||
}
|
||||
else if ( vDT.type() == QVariant::Date )
|
||||
{
|
||||
ret = vDT;
|
||||
}
|
||||
else if ( vDT.type() == QVariant::Time )
|
||||
{
|
||||
ret = vDT;
|
||||
}
|
||||
else
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
|
||||
// QDateTime dt = dateTime();
|
||||
// ret = dt;
|
||||
|
||||
QString strFormat = fmt.numberFormat();
|
||||
if (!strFormat.isEmpty())
|
||||
{
|
||||
// TODO: use number format
|
||||
}
|
||||
// QString strFormat = fmt.numberFormat();
|
||||
// if (!strFormat.isEmpty())
|
||||
// {
|
||||
// // TODO: use number format
|
||||
// }
|
||||
|
||||
qint32 styleNo = d->styleNumber;
|
||||
// qint32 styleNo = d->styleNumber;
|
||||
|
||||
if (styleNo == 10)
|
||||
{
|
||||
}
|
||||
// if (styleNo == 10)
|
||||
// {
|
||||
// }
|
||||
|
||||
if (styleNo == 11)
|
||||
{
|
||||
// if (styleNo == 11)
|
||||
// {
|
||||
// QTime timeValue = dt.time(); // only time. (HH:mm:ss)
|
||||
// ret = timeValue;
|
||||
// return ret;
|
||||
}
|
||||
// }
|
||||
|
||||
if (styleNo == 12)
|
||||
{
|
||||
}
|
||||
// if (styleNo == 12)
|
||||
// {
|
||||
// }
|
||||
|
||||
if (styleNo == 13) // (HH:mm:ss)
|
||||
{
|
||||
double dValue = d->value.toDouble();
|
||||
int day = int(dValue); // unit is day.
|
||||
double deciamlPointValue1 = dValue - double(day);
|
||||
// if (styleNo == 13) // (HH:mm:ss)
|
||||
// {
|
||||
// double dValue = d->value.toDouble();
|
||||
// int day = int(dValue); // unit is day.
|
||||
// double deciamlPointValue1 = dValue - double(day);
|
||||
|
||||
double dHour = deciamlPointValue1 * (double(1.0) / double(24.0));
|
||||
int hour = int(dHour);
|
||||
// double dHour = deciamlPointValue1 * (double(1.0) / double(24.0));
|
||||
// int hour = int(dHour);
|
||||
|
||||
double deciamlPointValue2 = deciamlPointValue1 - (double(hour) * (double(1.0) / double(24.0)));
|
||||
double dMin = deciamlPointValue2 * (double(1.0) / double(60.0));
|
||||
int min = int(dMin);
|
||||
// double deciamlPointValue2 = deciamlPointValue1 - (double(hour) * (double(1.0) / double(24.0)));
|
||||
// double dMin = deciamlPointValue2 * (double(1.0) / double(60.0));
|
||||
// int min = int(dMin);
|
||||
|
||||
double deciamlPointValue3 = deciamlPointValue2 - (double(min) * (double(1.0) / double(60.0)));
|
||||
double dSec = deciamlPointValue3 * (double(1.0) / double(60.0));
|
||||
int sec = int(dSec);
|
||||
// double deciamlPointValue3 = deciamlPointValue2 - (double(min) * (double(1.0) / double(60.0)));
|
||||
// double dSec = deciamlPointValue3 * (double(1.0) / double(60.0));
|
||||
// int sec = int(dSec);
|
||||
|
||||
int totalHour = hour + (day * 24);
|
||||
// int totalHour = hour + (day * 24);
|
||||
|
||||
QString strTime;
|
||||
strTime = QString("%1:%2:%3").arg(totalHour).arg(min).arg(sec);
|
||||
ret = strTime;
|
||||
// QString strTime;
|
||||
// strTime = QString("%1:%2:%3").arg(totalHour).arg(min).arg(sec);
|
||||
// ret = strTime;
|
||||
|
||||
return ret;
|
||||
}
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
return ret;
|
||||
// return ret;
|
||||
// */
|
||||
}
|
||||
|
||||
if (hasFormula())
|
||||
{
|
||||
// QVariant::Type vt = ret.type(); // it's double type.
|
||||
QString formulaString = this->formula().formulaText();
|
||||
ret = formulaString;
|
||||
return ret; // return formula string
|
||||
@ -246,6 +269,7 @@ bool Cell::isDateTime() const
|
||||
/*!
|
||||
* Return the data time value.
|
||||
*/
|
||||
/*
|
||||
QDateTime Cell::dateTime() const
|
||||
{
|
||||
Q_D(const Cell);
|
||||
@ -255,6 +279,16 @@ QDateTime Cell::dateTime() const
|
||||
|
||||
return datetimeFromNumber(d->value.toDouble(), d->parent->workbook()->isDate1904());
|
||||
}
|
||||
*/
|
||||
QVariant Cell::dateTime() const
|
||||
{
|
||||
Q_D(const Cell);
|
||||
|
||||
if (!isDateTime())
|
||||
return QVariant();
|
||||
|
||||
return datetimeFromNumber( d->value.toDouble(), d->parent->workbook()->isDate1904() );
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns whether the cell is probably a rich string or not
|
||||
|
@ -18,8 +18,7 @@
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QXlsx {
|
||||
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
XlsxColor::XlsxColor(const QColor &color)
|
||||
{
|
||||
@ -206,4 +205,5 @@ QDebug operator<<(QDebug dbg, const XlsxColor &c)
|
||||
|
||||
#endif
|
||||
|
||||
} // namespace QXlsx
|
||||
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
@ -30,7 +30,7 @@
|
||||
#include <QBuffer>
|
||||
#include <QDebug>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
ContentTypes::ContentTypes(CreateFlag flag)
|
||||
:AbstractOOXmlFile(flag)
|
||||
@ -202,4 +202,4 @@ bool ContentTypes::loadFromXmlFile(QIODevice *device)
|
||||
return true;
|
||||
}
|
||||
|
||||
} //namespace QXlsx
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
83
QXlsx/source/xlsxdatetype.cpp
Normal file
83
QXlsx/source/xlsxdatetype.cpp
Normal file
@ -0,0 +1,83 @@
|
||||
// xlsxdatetype.cpp
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
#include "xlsxutility_p.h"
|
||||
#include "xlsxdatetype.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
DateType::DateType()
|
||||
{
|
||||
}
|
||||
|
||||
/*
|
||||
DateType::DateType(bool is1904)
|
||||
{
|
||||
isSet = false;
|
||||
}
|
||||
|
||||
DateType::DateType(double d, bool is1904)
|
||||
{
|
||||
// TODO: check date
|
||||
|
||||
// int iVaue = (int) d;
|
||||
// double surplus = d - double(iVaue);
|
||||
|
||||
dValue = d;
|
||||
is1904Type = is1904;
|
||||
isSet = true;
|
||||
}
|
||||
|
||||
DateType::DateType(QDateTime qdt, bool is1904)
|
||||
{
|
||||
double ret = datetimeToNumber( qdt, is1904 );
|
||||
dValue = ret;
|
||||
is1904Type = is1904;
|
||||
isSet = true;
|
||||
}
|
||||
|
||||
DateType::DateType(QDate qd, bool is1904)
|
||||
{
|
||||
|
||||
is1904Type = is1904;
|
||||
isSet = true;
|
||||
}
|
||||
|
||||
DateType::DateType(QTime qt, bool is1904)
|
||||
{
|
||||
double ret = timeToNumber( qt );
|
||||
dValue = ret;
|
||||
is1904Type = is1904;
|
||||
isSet = true;
|
||||
}
|
||||
|
||||
// enum currentDateType { DateAndTimeType, OnlyDateType, OnlyTimeType };
|
||||
|
||||
DateType::currentDateType DateType::getType()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool DateType::getValue(QDateTime* pQdt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
bool DateType::getValue(QDate* pQd)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool DateType::getValue(QTime* pQt)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool DateType::getValue(double* pD)
|
||||
{
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
QT_END_NAMESPACE_XLSX
|
@ -31,7 +31,7 @@
|
||||
#include <QXmlStreamReader>
|
||||
#include <QBuffer>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
Drawing::Drawing(AbstractSheet *sheet, CreateFlag flag)
|
||||
:AbstractOOXmlFile(flag), sheet(sheet)
|
||||
@ -84,4 +84,4 @@ bool Drawing::loadFromXmlFile(QIODevice *device)
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace QXlsx
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
@ -35,7 +35,7 @@
|
||||
#include <QBuffer>
|
||||
#include <QDir>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
/*
|
||||
The vertices that define the position of a graphical object
|
||||
@ -971,4 +971,4 @@ bool DrawingTwoCellAnchor::loadFromXml(QXmlStreamReader &reader)
|
||||
}
|
||||
|
||||
|
||||
} // namespace QXlsx
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
@ -24,9 +24,10 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "xlsxmediafile_p.h"
|
||||
|
||||
#include <QCryptographicHash>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
MediaFile::MediaFile(const QByteArray &bytes, const QString &suffix, const QString &mimeType)
|
||||
: m_contents(bytes), m_suffix(suffix), m_mimeType(mimeType)
|
||||
@ -96,4 +97,4 @@ QByteArray MediaFile::hashKey() const
|
||||
return m_hashKey;
|
||||
}
|
||||
|
||||
} // namespace QXlsx
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
@ -1,32 +1,11 @@
|
||||
/****************************************************************************
|
||||
** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
|
||||
** All right reserved.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining
|
||||
** a copy of this software and associated documentation files (the
|
||||
** "Software"), to deal in the Software without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Software, and to
|
||||
** permit persons to whom the Software is furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be
|
||||
** included in all copies or substantial portions of the Software.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
**
|
||||
****************************************************************************/
|
||||
//
|
||||
|
||||
#include "xlsxnumformatparser_p.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QString>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
bool NumFormatParser::isDateTime(const QString &formatCode)
|
||||
{
|
||||
@ -91,4 +70,4 @@ bool NumFormatParser::isDateTime(const QString &formatCode)
|
||||
return false;
|
||||
}
|
||||
|
||||
} // namespace QXlsx
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include <QFile>
|
||||
#include <QBuffer>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
const QString schema_doc = QStringLiteral("http://schemas.openxmlformats.org/officeDocument/2006/relationships");
|
||||
const QString schema_msPackage = QStringLiteral("http://schemas.microsoft.com/office/2006/relationships");
|
||||
@ -186,4 +186,4 @@ bool Relationships::isEmpty() const
|
||||
return m_relationships.isEmpty();
|
||||
}
|
||||
|
||||
} //namespace
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
@ -1,32 +1,11 @@
|
||||
/****************************************************************************
|
||||
** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
|
||||
** All right reserved.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining
|
||||
** a copy of this software and associated documentation files (the
|
||||
** "Software"), to deal in the Software without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Software, and to
|
||||
** permit persons to whom the Software is furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be
|
||||
** included in all copies or substantial portions of the Software.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
**
|
||||
****************************************************************************/
|
||||
//
|
||||
|
||||
#include "xlsxrichstring.h"
|
||||
#include "xlsxsharedstrings_p.h"
|
||||
#include "xlsxutility_p.h"
|
||||
#include "xlsxformat_p.h"
|
||||
#include "xlsxcolor_p.h"
|
||||
|
||||
#include <QXmlStreamWriter>
|
||||
#include <QXmlStreamReader>
|
||||
#include <QDir>
|
||||
@ -34,7 +13,7 @@
|
||||
#include <QDebug>
|
||||
#include <QBuffer>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
/*
|
||||
* Note that, when we open an existing .xlsx file (broken file?),
|
||||
@ -398,4 +377,4 @@ bool SharedStrings::loadFromXmlFile(QIODevice *device)
|
||||
return true;
|
||||
}
|
||||
|
||||
} //namespace
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
@ -1,31 +1,12 @@
|
||||
/****************************************************************************
|
||||
** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
|
||||
** All right reserved.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining
|
||||
** a copy of this software and associated documentation files (the
|
||||
** "Software"), to deal in the Software without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Software, and to
|
||||
** permit persons to whom the Software is furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be
|
||||
** included in all copies or substantial portions of the Software.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
**
|
||||
****************************************************************************/
|
||||
//
|
||||
|
||||
#include "xlsxsimpleooxmlfile_p.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QIODevice>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
SimpleOOXmlFile::SimpleOOXmlFile(CreateFlag flag)
|
||||
:AbstractOOXmlFile(flag)
|
||||
{
|
||||
@ -53,4 +34,4 @@ bool SimpleOOXmlFile::loadFromXmlFile(QIODevice *device)
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
@ -23,7 +23,7 @@
|
||||
#include <QDebug>
|
||||
#include <QBuffer>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
/*
|
||||
When loading from existing .xlsx file. we should create a clean styles object.
|
||||
@ -1343,4 +1343,4 @@ QColor Styles::getColorByIndex(int idx)
|
||||
return m_indexedColors[idx];
|
||||
}
|
||||
|
||||
} //namespace QXlsx
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
@ -1,31 +1,10 @@
|
||||
/****************************************************************************
|
||||
** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
|
||||
** All right reserved.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining
|
||||
** a copy of this software and associated documentation files (the
|
||||
** "Software"), to deal in the Software without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Software, and to
|
||||
** permit persons to whom the Software is furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be
|
||||
** included in all copies or substantial portions of the Software.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
**
|
||||
****************************************************************************/
|
||||
//
|
||||
|
||||
#include "xlsxtheme_p.h"
|
||||
|
||||
#include <QIODevice>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
const char *defaultXmlData =
|
||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n"
|
||||
@ -234,4 +213,4 @@ bool Theme::loadFromXmlFile(QIODevice *device)
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
@ -34,6 +34,9 @@
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
|
||||
#include <cmath>
|
||||
#include <string>
|
||||
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
bool parseXsdBoolean(const QString &value, bool defaultValue)
|
||||
@ -100,24 +103,49 @@ double timeToNumber(const QTime &time)
|
||||
return QTime(0,0).msecsTo(time) / (1000*60*60*24.0);
|
||||
}
|
||||
|
||||
QDateTime datetimeFromNumber(double num, bool is1904)
|
||||
QVariant datetimeFromNumber(double num, bool is1904)
|
||||
{
|
||||
if (!is1904 && num > 60)
|
||||
if (!is1904 && num > 60) // for mac os excel
|
||||
{
|
||||
num = num - 1;
|
||||
}
|
||||
|
||||
qint64 msecs = static_cast<qint64>(num * 1000*60*60*24.0 + 0.5);
|
||||
QDateTime epoch(is1904 ? QDate(1904, 1, 1): QDate(1899, 12, 31), QTime(0,0));
|
||||
|
||||
QDateTime dt = epoch.addMSecs(msecs);
|
||||
QDateTime dt;
|
||||
|
||||
QDateTime dt1 = epoch.addMSecs(msecs);
|
||||
dt = dt1;
|
||||
|
||||
#if QT_VERSION >= 0x050200
|
||||
// Remove one hour to see whether the date is Daylight
|
||||
QDateTime dt2 = dt.addMSecs(-3600);
|
||||
if (dt2.isDaylightTime())
|
||||
return dt2;
|
||||
{
|
||||
dt = dt2;
|
||||
}
|
||||
#endif
|
||||
|
||||
return dt;
|
||||
float whole = 0;
|
||||
float fractional = std::modf(num, &whole);
|
||||
|
||||
if ( num < double(1) )
|
||||
{
|
||||
// only time
|
||||
QTime t = dt.time();
|
||||
return QVariant(t);
|
||||
}
|
||||
|
||||
if ( fractional == 0.0 )
|
||||
{
|
||||
// only date
|
||||
// qDebug() << "[debug] " << num << whole << fractional;
|
||||
QDate onlyDT = dt.date();
|
||||
return QVariant(onlyDT);
|
||||
}
|
||||
|
||||
return QVariant(dt);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -558,14 +558,18 @@ QVariant Worksheet::read(int row, int column) const
|
||||
}
|
||||
}
|
||||
|
||||
if (cell->isDateTime()) {
|
||||
double val = cell->value().toDouble();
|
||||
QDateTime dt = cell->dateTime();
|
||||
if (val < 1)
|
||||
return dt.time();
|
||||
if (fmod(val, 1.0) < 1.0/(1000*60*60*24)) //integer
|
||||
return dt.date();
|
||||
return dt;
|
||||
if (cell->isDateTime())
|
||||
{
|
||||
QVariant vDateTime = cell->dateTime();
|
||||
|
||||
// double val = cell->value().toDouble();
|
||||
// QDateTime dt = cell->dateTime();
|
||||
// if (val < 1)
|
||||
// return dt.time();
|
||||
// if (fmod(val, 1.0) < 1.0/(1000*60*60*24)) //integer
|
||||
// return dt.date();
|
||||
|
||||
return vDateTime;
|
||||
}
|
||||
|
||||
return cell->value();
|
||||
@ -1714,10 +1718,13 @@ QList<int> WorksheetPrivate ::getColumnIndexes(int colFirst, int colLast)
|
||||
|
||||
QList<int> nodes;
|
||||
nodes.append(colFirst);
|
||||
for (int col = colFirst; col <= colLast; ++col) {
|
||||
if (colsInfo.contains(col)) {
|
||||
for (int col = colFirst; col <= colLast; ++col)
|
||||
{
|
||||
if (colsInfo.contains(col))
|
||||
{
|
||||
if (nodes.last() != col)
|
||||
nodes.append(col);
|
||||
|
||||
int nextCol = colsInfo[col]->lastColumn + 1;
|
||||
if (nextCol <= colLast)
|
||||
nodes.append(nextCol);
|
||||
@ -1775,7 +1782,9 @@ bool Worksheet::setColumnWidth(int colFirst, int colLast, double width)
|
||||
|
||||
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = d->getColumnInfoList(colFirst, colLast);
|
||||
foreach(QSharedPointer<XlsxColumnInfo> columnInfo, columnInfoList)
|
||||
{
|
||||
columnInfo->width = width;
|
||||
}
|
||||
|
||||
return (columnInfoList.count() > 0);
|
||||
}
|
||||
@ -1823,11 +1832,30 @@ double Worksheet::columnWidth(int column)
|
||||
{
|
||||
Q_D(Worksheet);
|
||||
|
||||
QList <QSharedPointer<XlsxColumnInfo> > columnInfoList = d->getColumnInfoList(column, column);
|
||||
if (columnInfoList.count() == 1)
|
||||
return columnInfoList.at(0)->width ;
|
||||
QList< QSharedPointer<XlsxColumnInfo> > columnInfoList = d->getColumnInfoList(column, column);
|
||||
|
||||
return d->sheetFormatProps.defaultColWidth;
|
||||
// [dev54]
|
||||
if ( columnInfoList.size() == 0 )
|
||||
{
|
||||
// column information is not found
|
||||
// qDebug() << "[debug]" << __FUNCTION__ << "column (info) is not found. " << column;
|
||||
}
|
||||
|
||||
if (columnInfoList.count() == 1)
|
||||
{
|
||||
// column information is found
|
||||
// qDebug() << "[debug]" << __FUNCTION__ << "column (info) is found. " << column << oneColWidth;
|
||||
double oneColWidth = columnInfoList.at(0)->width;
|
||||
bool isSetWidth = columnInfoList.at(0)->isSetWidth;
|
||||
if ( isSetWidth )
|
||||
{
|
||||
return oneColWidth;
|
||||
}
|
||||
}
|
||||
|
||||
// use default width
|
||||
double defaultColWidth = d->sheetFormatProps.defaultColWidth;
|
||||
return defaultColWidth;
|
||||
}
|
||||
|
||||
/*!
|
||||
@ -1924,8 +1952,9 @@ double Worksheet::rowHeight(int row)
|
||||
int min_col = d->dimension.isValid() ? d->dimension.firstColumn() : 1;
|
||||
|
||||
if (d->checkDimensions(row, min_col, false, true) || !d->rowsInfo.contains(row))
|
||||
{
|
||||
return d->sheetFormatProps.defaultRowHeight; //return default on invalid row
|
||||
|
||||
}
|
||||
|
||||
return d->rowsInfo[row]->height;
|
||||
}
|
||||
@ -2019,16 +2048,20 @@ bool Worksheet::groupColumns(int colFirst, int colLast, bool collapsed)
|
||||
}
|
||||
}
|
||||
|
||||
for (int idx = 0; idx < nodes.size(); ++idx) {
|
||||
for (int idx = 0; idx < nodes.size(); ++idx)
|
||||
{
|
||||
int colStart = nodes[idx];
|
||||
if (d->colsInfo.contains(colStart)) {
|
||||
if (d->colsInfo.contains(colStart))
|
||||
{
|
||||
QSharedPointer<XlsxColumnInfo> info = d->colsInfo[colStart];
|
||||
info->outlineLevel += 1;
|
||||
if (collapsed)
|
||||
info->hidden = true;
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
int colEnd = (idx == nodes.size() - 1) ? colLast : nodes[idx+1] - 1;
|
||||
QSharedPointer<XlsxColumnInfo> info(new XlsxColumnInfo(colStart, colEnd));
|
||||
QSharedPointer<XlsxColumnInfo> info(new XlsxColumnInfo(colStart, colEnd, false));
|
||||
info->outlineLevel += 1;
|
||||
d->colsInfo.insert(colFirst, info);
|
||||
if (collapsed)
|
||||
@ -2044,7 +2077,7 @@ bool Worksheet::groupColumns(int colFirst, int colLast, bool collapsed)
|
||||
if (d->colsInfo.contains(col))
|
||||
d->colsInfo[col]->collapsed = true;
|
||||
else {
|
||||
QSharedPointer<XlsxColumnInfo> info(new XlsxColumnInfo(col, col));
|
||||
QSharedPointer<XlsxColumnInfo> info(new XlsxColumnInfo(col, col, false));
|
||||
info->collapsed = true;
|
||||
d->colsInfo.insert(col, info);
|
||||
d->colsInfoHelper[col] = info;
|
||||
@ -2123,15 +2156,19 @@ void WorksheetPrivate::loadXmlSheetData(QXmlStreamReader &reader)
|
||||
{
|
||||
|
||||
QSharedPointer<XlsxRowInfo> info(new XlsxRowInfo);
|
||||
if (attributes.hasAttribute(QLatin1String("customFormat")) && attributes.hasAttribute(QLatin1String("s"))) {
|
||||
if (attributes.hasAttribute(QLatin1String("customFormat")) &&
|
||||
attributes.hasAttribute(QLatin1String("s")))
|
||||
{
|
||||
int idx = attributes.value(QLatin1String("s")).toString().toInt();
|
||||
info->format = workbook->styles()->xfFormat(idx);
|
||||
}
|
||||
|
||||
if (attributes.hasAttribute(QLatin1String("customHeight"))) {
|
||||
if (attributes.hasAttribute(QLatin1String("customHeight")))
|
||||
{
|
||||
info->customHeight = attributes.value(QLatin1String("customHeight")) == QLatin1String("1");
|
||||
//Row height is only specified when customHeight is set
|
||||
if(attributes.hasAttribute(QLatin1String("ht"))) {
|
||||
if(attributes.hasAttribute(QLatin1String("ht")))
|
||||
{
|
||||
info->height = attributes.value(QLatin1String("ht")).toString().toDouble();
|
||||
}
|
||||
}
|
||||
@ -2144,7 +2181,8 @@ void WorksheetPrivate::loadXmlSheetData(QXmlStreamReader &reader)
|
||||
info->outlineLevel = attributes.value(QLatin1String("outlineLevel")).toString().toInt();
|
||||
|
||||
//"r" is optional too.
|
||||
if (attributes.hasAttribute(QLatin1String("r"))) {
|
||||
if (attributes.hasAttribute(QLatin1String("r")))
|
||||
{
|
||||
int row = attributes.value(QLatin1String("r")).toString().toInt();
|
||||
rowsInfo[row] = info;
|
||||
}
|
||||
@ -2231,7 +2269,8 @@ void WorksheetPrivate::loadXmlSheetData(QXmlStreamReader &reader)
|
||||
{
|
||||
CellFormula &formula = cell->d_func()->formula;
|
||||
formula.loadFromXml(reader);
|
||||
if (formula.formulaType() == CellFormula::SharedType && !formula.formulaText().isEmpty())
|
||||
if (formula.formulaType() == CellFormula::SharedType &&
|
||||
!formula.formulaText().isEmpty())
|
||||
{
|
||||
int si = formula.sharedIndex();
|
||||
sharedFormulaMap[ si ] = formula;
|
||||
@ -2239,8 +2278,6 @@ void WorksheetPrivate::loadXmlSheetData(QXmlStreamReader &reader)
|
||||
}
|
||||
else if (reader.name() == QLatin1String("v")) // Value
|
||||
{
|
||||
// NOTICE: CHECK POINT
|
||||
|
||||
QString value = reader.readElementText();
|
||||
if (cellType == Cell::SharedStringType)
|
||||
{
|
||||
@ -2264,29 +2301,11 @@ void WorksheetPrivate::loadXmlSheetData(QXmlStreamReader &reader)
|
||||
{
|
||||
// [dev54] DateType
|
||||
|
||||
double dValue = value.toDouble(); // days from 1900
|
||||
int iValue = (int) dValue; // days from 1900 (integer)
|
||||
double dTime = dValue - double(dValue); // time (under date)
|
||||
|
||||
double dValue = value.toDouble(); // days from 1900(or 1904)
|
||||
bool bIsDate1904 = q->workbook()->isDate1904();
|
||||
QDateTime datetimeValue = datetimeFromNumber( dValue, bIsDate1904 );
|
||||
cell->d_func()->value = datetimeValue;
|
||||
|
||||
if ( dValue < double(1) ) // only time
|
||||
{
|
||||
QDate nullDate;
|
||||
QTime timeValue = datetimeValue.time();
|
||||
cell->d_func()->value = QDateTime( nullDate, timeValue );
|
||||
}
|
||||
|
||||
double cmpDValue = double(iValue);
|
||||
if ( dValue == cmpDValue ) // only date
|
||||
{
|
||||
QDate dateValue = datetimeValue.date();
|
||||
QTime nullTime; // null time is (Hout:Minute:Second)=(0:0:0).
|
||||
cell->d_func()->value = QDateTime( dateValue, nullTime );
|
||||
}
|
||||
|
||||
QVariant vDatetimeValue = datetimeFromNumber( dValue, bIsDate1904 );
|
||||
cell->d_func()->value = vDatetimeValue;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -2335,11 +2354,16 @@ void WorksheetPrivate::loadXmlColumnsInfo(QXmlStreamReader &reader)
|
||||
{
|
||||
Q_ASSERT(reader.name() == QLatin1String("cols"));
|
||||
|
||||
while (!reader.atEnd() && !(reader.name() == QLatin1String("cols") && reader.tokenType() == QXmlStreamReader::EndElement)) {
|
||||
while (!reader.atEnd() &&
|
||||
!(reader.name() == QLatin1String("cols") &&
|
||||
reader.tokenType() == QXmlStreamReader::EndElement))
|
||||
{
|
||||
reader.readNextStartElement();
|
||||
if (reader.tokenType() == QXmlStreamReader::StartElement) {
|
||||
if (reader.name() == QLatin1String("col")) {
|
||||
QSharedPointer<XlsxColumnInfo> info(new XlsxColumnInfo);
|
||||
if (reader.tokenType() == QXmlStreamReader::StartElement)
|
||||
{
|
||||
if (reader.name() == QLatin1String("col"))
|
||||
{
|
||||
QSharedPointer<XlsxColumnInfo> info(new XlsxColumnInfo(0, 1, false));
|
||||
|
||||
QXmlStreamAttributes colAttrs = reader.attributes();
|
||||
int min = colAttrs.value(QLatin1String("min")).toString().toInt();
|
||||
@ -2349,28 +2373,41 @@ void WorksheetPrivate::loadXmlColumnsInfo(QXmlStreamReader &reader)
|
||||
|
||||
//Flag indicating that the column width for the affected column(s) is different from the
|
||||
// default or has been manually set
|
||||
if(colAttrs.hasAttribute(QLatin1String("customWidth"))) {
|
||||
if(colAttrs.hasAttribute(QLatin1String("customWidth")))
|
||||
{
|
||||
info->customWidth = colAttrs.value(QLatin1String("customWidth")) == QLatin1String("1");
|
||||
}
|
||||
|
||||
//Note, node may have "width" without "customWidth"
|
||||
if (colAttrs.hasAttribute(QLatin1String("width"))) {
|
||||
// [dev54]
|
||||
if (colAttrs.hasAttribute(QLatin1String("width")))
|
||||
{
|
||||
double width = colAttrs.value(QLatin1String("width")).toString().toDouble();
|
||||
info->width = width;
|
||||
info->isSetWidth = true; // [dev54]
|
||||
}
|
||||
|
||||
info->hidden = colAttrs.value(QLatin1String("hidden")) == QLatin1String("1");
|
||||
info->collapsed = colAttrs.value(QLatin1String("collapsed")) == QLatin1String("1");
|
||||
|
||||
if (colAttrs.hasAttribute(QLatin1String("style"))) {
|
||||
if (colAttrs.hasAttribute(QLatin1String("style")))
|
||||
{
|
||||
int idx = colAttrs.value(QLatin1String("style")).toString().toInt();
|
||||
info->format = workbook->styles()->xfFormat(idx);
|
||||
}
|
||||
|
||||
if (colAttrs.hasAttribute(QLatin1String("outlineLevel")))
|
||||
{
|
||||
info->outlineLevel = colAttrs.value(QLatin1String("outlineLevel")).toString().toInt();
|
||||
}
|
||||
|
||||
// qDebug() << "[debug] " << __FUNCTION__ << min << max << info->width << hasWidth;
|
||||
|
||||
colsInfo.insert(min, info);
|
||||
for (int col=min; col<=max; ++col)
|
||||
for (int col = min ; col <= max ; ++col)
|
||||
{
|
||||
colsInfoHelper[col] = info;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -2445,42 +2482,73 @@ void WorksheetPrivate::loadXmlSheetViews(QXmlStreamReader &reader)
|
||||
void WorksheetPrivate::loadXmlSheetFormatProps(QXmlStreamReader &reader)
|
||||
{
|
||||
Q_ASSERT(reader.name() == QLatin1String("sheetFormatPr"));
|
||||
|
||||
QXmlStreamAttributes attributes = reader.attributes();
|
||||
XlsxSheetFormatProps formatProps;
|
||||
bool isSetWidth = false;
|
||||
|
||||
//Retain default values
|
||||
foreach (QXmlStreamAttribute attrib, attributes) {
|
||||
if(attrib.name() == QLatin1String("baseColWidth") ) {
|
||||
// Retain default values
|
||||
foreach (QXmlStreamAttribute attrib, attributes)
|
||||
{
|
||||
if(attrib.name() == QLatin1String("baseColWidth") )
|
||||
{
|
||||
formatProps.baseColWidth = attrib.value().toString().toInt();
|
||||
} else if(attrib.name() == QLatin1String("customHeight")) {
|
||||
}
|
||||
else if(attrib.name() == QLatin1String("customHeight"))
|
||||
{
|
||||
formatProps.customHeight = attrib.value() == QLatin1String("1");
|
||||
} else if(attrib.name() == QLatin1String("defaultColWidth")) {
|
||||
formatProps.defaultColWidth = attrib.value().toString().toDouble();
|
||||
} else if(attrib.name() == QLatin1String("defaultRowHeight")) {
|
||||
}
|
||||
else if(attrib.name() == QLatin1String("defaultColWidth"))
|
||||
{
|
||||
double dDefaultColWidth = attrib.value().toString().toDouble();
|
||||
formatProps.defaultColWidth = dDefaultColWidth;
|
||||
isSetWidth = true;
|
||||
}
|
||||
else if(attrib.name() == QLatin1String("defaultRowHeight"))
|
||||
{
|
||||
formatProps.defaultRowHeight = attrib.value().toString().toDouble();
|
||||
} else if(attrib.name() == QLatin1String("outlineLevelCol")) {
|
||||
}
|
||||
else if(attrib.name() == QLatin1String("outlineLevelCol"))
|
||||
{
|
||||
formatProps.outlineLevelCol = attrib.value().toString().toInt();
|
||||
} else if(attrib.name() == QLatin1String("outlineLevelRow")) {
|
||||
}
|
||||
else if(attrib.name() == QLatin1String("outlineLevelRow"))
|
||||
{
|
||||
formatProps.outlineLevelRow = attrib.value().toString().toInt();
|
||||
} else if(attrib.name() == QLatin1String("thickBottom")) {
|
||||
}
|
||||
else if(attrib.name() == QLatin1String("thickBottom"))
|
||||
{
|
||||
formatProps.thickBottom = attrib.value() == QLatin1String("1");
|
||||
} else if(attrib.name() == QLatin1String("thickTop")) {
|
||||
}
|
||||
else if(attrib.name() == QLatin1String("thickTop"))
|
||||
{
|
||||
formatProps.thickTop = attrib.value() == QLatin1String("1");
|
||||
} else if(attrib.name() == QLatin1String("zeroHeight")) {
|
||||
}
|
||||
else if(attrib.name() == QLatin1String("zeroHeight"))
|
||||
{
|
||||
formatProps.zeroHeight = attrib.value() == QLatin1String("1");
|
||||
}
|
||||
}
|
||||
|
||||
if(formatProps.defaultColWidth == 0.0) { //not set
|
||||
formatProps.defaultColWidth = WorksheetPrivate::calculateColWidth(formatProps.baseColWidth);
|
||||
// if (formatProps.defaultColWidth == 0.0)
|
||||
if ( !isSetWidth )
|
||||
{
|
||||
//not set
|
||||
double dCalcWidth = WorksheetPrivate::calculateColWidth(formatProps.baseColWidth);
|
||||
formatProps.defaultColWidth = dCalcWidth;
|
||||
}
|
||||
|
||||
// [dev54]
|
||||
// Where is code of setting 'formatProps'?
|
||||
this->sheetFormatProps = formatProps;
|
||||
|
||||
}
|
||||
double WorksheetPrivate::calculateColWidth(int characters)
|
||||
{
|
||||
//!Todo
|
||||
// //!Todo
|
||||
//Take normal style' font maximum width and add padding and margin pixels
|
||||
return characters + 0.5;
|
||||
// return characters + 0.5;
|
||||
return characters;
|
||||
}
|
||||
|
||||
void WorksheetPrivate::loadXmlHyperlinks(QXmlStreamReader &reader)
|
||||
@ -2516,22 +2584,28 @@ void WorksheetPrivate::loadXmlHyperlinks(QXmlStreamReader &reader)
|
||||
QList <QSharedPointer<XlsxColumnInfo> > WorksheetPrivate::getColumnInfoList(int colFirst, int colLast)
|
||||
{
|
||||
QList <QSharedPointer<XlsxColumnInfo> > columnsInfoList;
|
||||
if(isColumnRangeValid(colFirst,colLast))
|
||||
if (isColumnRangeValid(colFirst,colLast))
|
||||
{
|
||||
QList<int> nodes = getColumnIndexes(colFirst, colLast);
|
||||
|
||||
for (int idx = 0; idx < nodes.size(); ++idx) {
|
||||
for (int idx = 0; idx < nodes.size(); ++idx)
|
||||
{
|
||||
int colStart = nodes[idx];
|
||||
if (colsInfo.contains(colStart)) {
|
||||
if (colsInfo.contains(colStart))
|
||||
{
|
||||
QSharedPointer<XlsxColumnInfo> info = colsInfo[colStart];
|
||||
columnsInfoList.append(info);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
int colEnd = (idx == nodes.size() - 1) ? colLast : nodes[idx+1] - 1;
|
||||
QSharedPointer<XlsxColumnInfo> info(new XlsxColumnInfo(colStart, colEnd));
|
||||
QSharedPointer<XlsxColumnInfo> info(new XlsxColumnInfo(colStart, colEnd, false));
|
||||
colsInfo.insert(colFirst, info);
|
||||
columnsInfoList.append(info);
|
||||
for (int c = colStart; c <= colEnd; ++c)
|
||||
{
|
||||
colsInfoHelper[c] = info;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include <private/qzipreader_p.h>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
ZipReader::ZipReader(const QString &filePath) :
|
||||
m_reader(new QZipReader(filePath))
|
||||
@ -74,4 +74,4 @@ QByteArray ZipReader::fileData(const QString &fileName) const
|
||||
return m_reader->fileData(fileName);
|
||||
}
|
||||
|
||||
} // namespace QXlsx
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
@ -1,32 +1,12 @@
|
||||
/****************************************************************************
|
||||
** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
|
||||
** All right reserved.
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining
|
||||
** a copy of this software and associated documentation files (the
|
||||
** "Software"), to deal in the Software without restriction, including
|
||||
** without limitation the rights to use, copy, modify, merge, publish,
|
||||
** distribute, sublicense, and/or sell copies of the Software, and to
|
||||
** permit persons to whom the Software is furnished to do so, subject to
|
||||
** the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be
|
||||
** included in all copies or substantial portions of the Software.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
**
|
||||
****************************************************************************/
|
||||
//
|
||||
|
||||
#include "xlsxzipwriter_p.h"
|
||||
|
||||
#include <QtGlobal>
|
||||
#include <QDebug>
|
||||
#include <private/qzipwriter_p.h>
|
||||
|
||||
namespace QXlsx {
|
||||
QT_BEGIN_NAMESPACE_XLSX
|
||||
|
||||
ZipWriter::ZipWriter(const QString &filePath)
|
||||
{
|
||||
@ -65,4 +45,4 @@ void ZipWriter::close()
|
||||
m_writer->close();
|
||||
}
|
||||
|
||||
} // namespace QXlsx
|
||||
QT_END_NAMESPACE_XLSX
|
||||
|
@ -30,13 +30,10 @@ Travis CI | AppVeyor | CodeFactor
|
||||
|
||||
- [테스트된 환경](TestEnv.md) 참조
|
||||
|
||||
## 이슈
|
||||
|
||||
[![Waffle.io - Columns and their card count](https://badge.waffle.io/QtExcel/QXlsx.svg?columns=all)](https://waffle.io/QtExcel/QXlsx)
|
||||
|
||||
## 할 일
|
||||
- [테스트 할 일](ToTest.md)
|
||||
- [업그레이드 할 일](ToUpgrade.md)
|
||||
- [비전](Vision.md)
|
||||
|
||||
## 컨트리뷰터
|
||||
- [컨트리뷰터](https://github.com/QtExcel/QXlsx/graphs/contributors) 참조.
|
||||
|
@ -30,13 +30,10 @@ Travis CI | AppVeyor | CodeFactor
|
||||
|
||||
- See [tested environments](TestEnv.md)
|
||||
|
||||
## Issue
|
||||
|
||||
[![Waffle.io - Columns and their card count](https://badge.waffle.io/QtExcel/QXlsx.svg?columns=all)](https://waffle.io/QtExcel/QXlsx)
|
||||
|
||||
## To Do
|
||||
- [To test](ToTest.md)
|
||||
- [What to upgrade](ToUpgrade.md).
|
||||
- [Vision](Vision.md)
|
||||
|
||||
## Contributions
|
||||
- See [contributors](https://github.com/QtExcel/QXlsx/graphs/contributors).
|
||||
|
Loading…
x
Reference in New Issue
Block a user