Make private class XlsxCellData as public QXlsx::Cell
This commit is contained in:
+5
-2
@@ -26,7 +26,9 @@ HEADERS += $$PWD/xlsxdocpropscore_p.h \
|
|||||||
$$PWD/xlsxxmlreader_p.h \
|
$$PWD/xlsxxmlreader_p.h \
|
||||||
$$PWD/xlsxzipreader_p.h \
|
$$PWD/xlsxzipreader_p.h \
|
||||||
$$PWD/xlsxdocument.h \
|
$$PWD/xlsxdocument.h \
|
||||||
$$PWD/xlsxdocument_p.h
|
$$PWD/xlsxdocument_p.h \
|
||||||
|
$$PWD/xlsxcell.h \
|
||||||
|
$$PWD/xlsxcell_p.h
|
||||||
|
|
||||||
SOURCES += $$PWD/xlsxdocpropscore.cpp \
|
SOURCES += $$PWD/xlsxdocpropscore.cpp \
|
||||||
$$PWD/xlsxdocpropsapp.cpp \
|
$$PWD/xlsxdocpropsapp.cpp \
|
||||||
@@ -45,4 +47,5 @@ SOURCES += $$PWD/xlsxdocpropscore.cpp \
|
|||||||
$$PWD/xlsxdrawing.cpp \
|
$$PWD/xlsxdrawing.cpp \
|
||||||
$$PWD/xlsxxmlreader.cpp \
|
$$PWD/xlsxxmlreader.cpp \
|
||||||
$$PWD/xlsxzipreader.cpp \
|
$$PWD/xlsxzipreader.cpp \
|
||||||
$$PWD/xlsxdocument.cpp
|
$$PWD/xlsxdocument.cpp \
|
||||||
|
$$PWD/xlsxcell.cpp
|
||||||
|
|||||||
@@ -0,0 +1,79 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** Copyright (c) 2013 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 "xlsxcell.h"
|
||||||
|
#include "xlsxcell_p.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
|
CellPrivate::CellPrivate(Cell *p) :
|
||||||
|
q_ptr(p)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\class Cell
|
||||||
|
\inmodule QtXlsx
|
||||||
|
\brief The Cell class provides a API that is used to handle the worksheet cell.
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
/*!
|
||||||
|
* \internal
|
||||||
|
* Created by Worksheet only.
|
||||||
|
*/
|
||||||
|
Cell::Cell(const QVariant &data, DataType type, Format *format) :
|
||||||
|
d_ptr(new CellPrivate(this))
|
||||||
|
{
|
||||||
|
d_ptr->value = data;
|
||||||
|
d_ptr->dataType = type;
|
||||||
|
d_ptr->format = format;
|
||||||
|
}
|
||||||
|
|
||||||
|
Cell::DataType Cell::dataType() const
|
||||||
|
{
|
||||||
|
Q_D(const Cell);
|
||||||
|
return d->dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant Cell::value() const
|
||||||
|
{
|
||||||
|
Q_D(const Cell);
|
||||||
|
return d->value;
|
||||||
|
}
|
||||||
|
|
||||||
|
Format *Cell::format() const
|
||||||
|
{
|
||||||
|
Q_D(const Cell);
|
||||||
|
return d->format;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString Cell::formula() const
|
||||||
|
{
|
||||||
|
Q_D(const Cell);
|
||||||
|
return d->formula;
|
||||||
|
}
|
||||||
|
|
||||||
|
QT_END_NAMESPACE_XLSX
|
||||||
@@ -0,0 +1,68 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** Copyright (c) 2013 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 QXLSX_XLSXCELL_H
|
||||||
|
#define QXLSX_XLSXCELL_H
|
||||||
|
|
||||||
|
#include "xlsxglobal.h"
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
|
class Worksheet;
|
||||||
|
class Format;
|
||||||
|
class CellPrivate;
|
||||||
|
class WorksheetPrivate;
|
||||||
|
|
||||||
|
class Q_XLSX_EXPORT Cell
|
||||||
|
{
|
||||||
|
Q_DECLARE_PRIVATE(Cell)
|
||||||
|
public:
|
||||||
|
enum DataType {
|
||||||
|
Blank,
|
||||||
|
String,
|
||||||
|
Number,
|
||||||
|
Formula,
|
||||||
|
ArrayFormula,
|
||||||
|
Boolean,
|
||||||
|
DateTime
|
||||||
|
};
|
||||||
|
|
||||||
|
DataType dataType() const;
|
||||||
|
QVariant value() const;
|
||||||
|
Format * format() const;
|
||||||
|
QString formula() const;
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class Worksheet;
|
||||||
|
friend class WorksheetPrivate;
|
||||||
|
|
||||||
|
Cell(const QVariant &data=QVariant(), DataType type=Blank, Format *format=0);
|
||||||
|
|
||||||
|
CellPrivate * const d_ptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE_XLSX
|
||||||
|
|
||||||
|
#endif // QXLSX_XLSXCELL_H
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
/****************************************************************************
|
||||||
|
** Copyright (c) 2013 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 XLSXCELL_P_H
|
||||||
|
#include "xlsxglobal.h"
|
||||||
|
#include "xlsxcell.h"
|
||||||
|
|
||||||
|
QT_BEGIN_NAMESPACE_XLSX
|
||||||
|
|
||||||
|
class CellPrivate
|
||||||
|
{
|
||||||
|
Q_DECLARE_PUBLIC(Cell)
|
||||||
|
public:
|
||||||
|
CellPrivate(Cell *p);
|
||||||
|
|
||||||
|
QVariant value;
|
||||||
|
QString formula;
|
||||||
|
Cell::DataType dataType;
|
||||||
|
Format *format;
|
||||||
|
|
||||||
|
Cell *q_ptr;
|
||||||
|
};
|
||||||
|
|
||||||
|
QT_END_NAMESPACE_XLSX
|
||||||
|
#define XLSXCELL_P_H
|
||||||
|
|
||||||
|
#endif // XLSXCELL_P_H
|
||||||
+33
-31
@@ -32,6 +32,8 @@
|
|||||||
#include "xlsxxmlreader_p.h"
|
#include "xlsxxmlreader_p.h"
|
||||||
#include "xlsxdrawing_p.h"
|
#include "xlsxdrawing_p.h"
|
||||||
#include "xlsxstyles_p.h"
|
#include "xlsxstyles_p.h"
|
||||||
|
#include "xlsxcell.h"
|
||||||
|
#include "xlsxcell_p.h"
|
||||||
|
|
||||||
#include <QVariant>
|
#include <QVariant>
|
||||||
#include <QDateTime>
|
#include <QDateTime>
|
||||||
@@ -351,7 +353,7 @@ int Worksheet::writeString(int row, int column, const QString &value, Format *fo
|
|||||||
SharedStrings *sharedStrings = d->workbook->sharedStrings();
|
SharedStrings *sharedStrings = d->workbook->sharedStrings();
|
||||||
int index = sharedStrings->addSharedString(content);
|
int index = sharedStrings->addSharedString(content);
|
||||||
|
|
||||||
d->cellTable[row][column] = QSharedPointer<XlsxCellData>(new XlsxCellData(index, XlsxCellData::String, format));
|
d->cellTable[row][column] = QSharedPointer<Cell>(new Cell(index, Cell::String, format));
|
||||||
d->workbook->styles()->addFormat(format);
|
d->workbook->styles()->addFormat(format);
|
||||||
return error;
|
return error;
|
||||||
}
|
}
|
||||||
@@ -362,7 +364,7 @@ int Worksheet::writeNumber(int row, int column, double value, Format *format)
|
|||||||
if (d->checkDimensions(row, column))
|
if (d->checkDimensions(row, column))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
d->cellTable[row][column] = QSharedPointer<XlsxCellData>(new XlsxCellData(value, XlsxCellData::Number, format));
|
d->cellTable[row][column] = QSharedPointer<Cell>(new Cell(value, Cell::Number, format));
|
||||||
d->workbook->styles()->addFormat(format);
|
d->workbook->styles()->addFormat(format);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -379,9 +381,9 @@ int Worksheet::writeFormula(int row, int column, const QString &content, Format
|
|||||||
if (formula.startsWith(QLatin1String("=")))
|
if (formula.startsWith(QLatin1String("=")))
|
||||||
formula.remove(0,1);
|
formula.remove(0,1);
|
||||||
|
|
||||||
XlsxCellData *data = new XlsxCellData(result, XlsxCellData::Formula, format);
|
Cell *data = new Cell(result, Cell::Formula, format);
|
||||||
data->formula = formula;
|
data->d_ptr->formula = formula;
|
||||||
d->cellTable[row][column] = QSharedPointer<XlsxCellData>(data);
|
d->cellTable[row][column] = QSharedPointer<Cell>(data);
|
||||||
d->workbook->styles()->addFormat(format);
|
d->workbook->styles()->addFormat(format);
|
||||||
|
|
||||||
return error;
|
return error;
|
||||||
@@ -393,7 +395,7 @@ int Worksheet::writeBlank(int row, int column, Format *format)
|
|||||||
if (d->checkDimensions(row, column))
|
if (d->checkDimensions(row, column))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
d->cellTable[row][column] = QSharedPointer<XlsxCellData>(new XlsxCellData(QVariant(), XlsxCellData::Blank, format));
|
d->cellTable[row][column] = QSharedPointer<Cell>(new Cell(QVariant(), Cell::Blank, format));
|
||||||
d->workbook->styles()->addFormat(format);
|
d->workbook->styles()->addFormat(format);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -405,7 +407,7 @@ int Worksheet::writeBool(int row, int column, bool value, Format *format)
|
|||||||
if (d->checkDimensions(row, column))
|
if (d->checkDimensions(row, column))
|
||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
d->cellTable[row][column] = QSharedPointer<XlsxCellData>(new XlsxCellData(value, XlsxCellData::Boolean, format));
|
d->cellTable[row][column] = QSharedPointer<Cell>(new Cell(value, Cell::Boolean, format));
|
||||||
d->workbook->styles()->addFormat(format);
|
d->workbook->styles()->addFormat(format);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -421,7 +423,7 @@ int Worksheet::writeDateTime(int row, int column, const QDateTime &dt, Format *f
|
|||||||
format = d->workbook->createFormat();
|
format = d->workbook->createFormat();
|
||||||
format->setNumberFormat(d->workbook->defaultDateFormat());
|
format->setNumberFormat(d->workbook->defaultDateFormat());
|
||||||
}
|
}
|
||||||
d->cellTable[row][column] = QSharedPointer<XlsxCellData>(new XlsxCellData(dt, XlsxCellData::DateTime, format));
|
d->cellTable[row][column] = QSharedPointer<Cell>(new Cell(dt, Cell::DateTime, format));
|
||||||
d->workbook->styles()->addFormat(format);
|
d->workbook->styles()->addFormat(format);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -483,7 +485,7 @@ int Worksheet::writeUrl(int row, int column, const QUrl &url, Format *format, co
|
|||||||
//Write the hyperlink string as normal string.
|
//Write the hyperlink string as normal string.
|
||||||
SharedStrings *sharedStrings = d->workbook->sharedStrings();
|
SharedStrings *sharedStrings = d->workbook->sharedStrings();
|
||||||
int index = sharedStrings->addSharedString(urlString);
|
int index = sharedStrings->addSharedString(urlString);
|
||||||
d->cellTable[row][column] = QSharedPointer<XlsxCellData>(new XlsxCellData(index, XlsxCellData::String, format));
|
d->cellTable[row][column] = QSharedPointer<Cell>(new Cell(index, Cell::String, format));
|
||||||
|
|
||||||
//Store the hyperlink data in sa separate table
|
//Store the hyperlink data in sa separate table
|
||||||
d->urlTable[row][column] = new XlsxUrlData(link_type, urlString, locationString, tip);
|
d->urlTable[row][column] = new XlsxUrlData(link_type, urlString, locationString, tip);
|
||||||
@@ -697,7 +699,7 @@ void WorksheetPrivate::writeSheetData(XmlStreamWriter &writer)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorksheetPrivate::writeCellData(XmlStreamWriter &writer, int row, int col, QSharedPointer<XlsxCellData> cell)
|
void WorksheetPrivate::writeCellData(XmlStreamWriter &writer, int row, int col, QSharedPointer<Cell> cell)
|
||||||
{
|
{
|
||||||
//This is the innermost loop so efficiency is important.
|
//This is the innermost loop so efficiency is important.
|
||||||
QString cell_range = xl_rowcol_to_cell_fast(row, col);
|
QString cell_range = xl_rowcol_to_cell_fast(row, col);
|
||||||
@@ -706,39 +708,39 @@ void WorksheetPrivate::writeCellData(XmlStreamWriter &writer, int row, int col,
|
|||||||
writer.writeAttribute(QStringLiteral("r"), cell_range);
|
writer.writeAttribute(QStringLiteral("r"), cell_range);
|
||||||
|
|
||||||
//Style used by the cell, row or col
|
//Style used by the cell, row or col
|
||||||
if (cell->format)
|
if (cell->format())
|
||||||
writer.writeAttribute(QStringLiteral("s"), QString::number(cell->format->xfIndex()));
|
writer.writeAttribute(QStringLiteral("s"), QString::number(cell->format()->xfIndex()));
|
||||||
else if (rowsInfo.contains(row) && rowsInfo[row]->format)
|
else if (rowsInfo.contains(row) && rowsInfo[row]->format)
|
||||||
writer.writeAttribute(QStringLiteral("s"), QString::number(rowsInfo[row]->format->xfIndex()));
|
writer.writeAttribute(QStringLiteral("s"), QString::number(rowsInfo[row]->format->xfIndex()));
|
||||||
else if (colsInfoHelper.contains(col) && colsInfoHelper[col]->format)
|
else if (colsInfoHelper.contains(col) && colsInfoHelper[col]->format)
|
||||||
writer.writeAttribute(QStringLiteral("s"), QString::number(colsInfoHelper[col]->format->xfIndex()));
|
writer.writeAttribute(QStringLiteral("s"), QString::number(colsInfoHelper[col]->format->xfIndex()));
|
||||||
|
|
||||||
if (cell->dataType == XlsxCellData::String) {
|
if (cell->dataType() == Cell::String) {
|
||||||
//cell->data: Index of the string in sharedStringTable
|
//cell->data: Index of the string in sharedStringTable
|
||||||
writer.writeAttribute(QStringLiteral("t"), QStringLiteral("s"));
|
writer.writeAttribute(QStringLiteral("t"), QStringLiteral("s"));
|
||||||
writer.writeTextElement(QStringLiteral("v"), cell->value.toString());
|
writer.writeTextElement(QStringLiteral("v"), cell->value().toString());
|
||||||
} else if (cell->dataType == XlsxCellData::Number){
|
} else if (cell->dataType() == Cell::Number){
|
||||||
double value = cell->value.toDouble();
|
double value = cell->value().toDouble();
|
||||||
writer.writeTextElement(QStringLiteral("v"), QString::number(value, 'g', 15));
|
writer.writeTextElement(QStringLiteral("v"), QString::number(value, 'g', 15));
|
||||||
} else if (cell->dataType == XlsxCellData::Formula) {
|
} else if (cell->dataType() == Cell::Formula) {
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
cell->formula.toDouble(&ok);
|
cell->formula().toDouble(&ok);
|
||||||
if (!ok) //is string
|
if (!ok) //is string
|
||||||
writer.writeAttribute(QStringLiteral("t"), QStringLiteral("str"));
|
writer.writeAttribute(QStringLiteral("t"), QStringLiteral("str"));
|
||||||
writer.writeTextElement(QStringLiteral("f"), cell->formula);
|
writer.writeTextElement(QStringLiteral("f"), cell->formula());
|
||||||
writer.writeTextElement(QStringLiteral("v"), cell->value.toString());
|
writer.writeTextElement(QStringLiteral("v"), cell->value().toString());
|
||||||
} else if (cell->dataType == XlsxCellData::ArrayFormula) {
|
} else if (cell->dataType() == Cell::ArrayFormula) {
|
||||||
|
|
||||||
} else if (cell->dataType == XlsxCellData::Boolean) {
|
} else if (cell->dataType() == Cell::Boolean) {
|
||||||
writer.writeAttribute(QStringLiteral("t"), QStringLiteral("b"));
|
writer.writeAttribute(QStringLiteral("t"), QStringLiteral("b"));
|
||||||
writer.writeTextElement(QStringLiteral("v"), cell->value.toBool() ? QStringLiteral("1") : QStringLiteral("0"));
|
writer.writeTextElement(QStringLiteral("v"), cell->value().toBool() ? QStringLiteral("1") : QStringLiteral("0"));
|
||||||
} else if (cell->dataType == XlsxCellData::Blank) {
|
} else if (cell->dataType() == Cell::Blank) {
|
||||||
//Ok, empty here.
|
//Ok, empty here.
|
||||||
} else if (cell->dataType == XlsxCellData::DateTime) {
|
} else if (cell->dataType() == Cell::DateTime) {
|
||||||
QDateTime epoch(QDate(1899, 12, 31));
|
QDateTime epoch(QDate(1899, 12, 31));
|
||||||
if (workbook->isDate1904())
|
if (workbook->isDate1904())
|
||||||
epoch = QDateTime(QDate(1904, 1, 1));
|
epoch = QDateTime(QDate(1904, 1, 1));
|
||||||
qint64 delta = epoch.msecsTo(cell->value.toDateTime());
|
qint64 delta = epoch.msecsTo(cell->value().toDateTime());
|
||||||
double excel_time = delta / (1000*60*60*24);
|
double excel_time = delta / (1000*60*60*24);
|
||||||
//Account for Excel erroneously treating 1900 as a leap year.
|
//Account for Excel erroneously treating 1900 as a leap year.
|
||||||
if (!workbook->isDate1904() && excel_time > 59)
|
if (!workbook->isDate1904() && excel_time > 59)
|
||||||
@@ -1115,15 +1117,15 @@ void WorksheetPrivate::readSheetData(XmlStreamReader &reader)
|
|||||||
if (reader.name() == QLatin1String("v")) {
|
if (reader.name() == QLatin1String("v")) {
|
||||||
QString value = reader.readElementText();
|
QString value = reader.readElementText();
|
||||||
workbook->sharedStrings()->incRefByStringIndex(value.toInt());
|
workbook->sharedStrings()->incRefByStringIndex(value.toInt());
|
||||||
XlsxCellData *data = new XlsxCellData(value ,XlsxCellData::String, format);
|
Cell *data = new Cell(value ,Cell::String, format);
|
||||||
cellTable[pos.x()][pos.y()] = QSharedPointer<XlsxCellData>(data);
|
cellTable[pos.x()][pos.y()] = QSharedPointer<Cell>(data);
|
||||||
}
|
}
|
||||||
} else if (type == QLatin1String("b")) {
|
} else if (type == QLatin1String("b")) {
|
||||||
//bool type
|
//bool type
|
||||||
reader.readNextStartElement();
|
reader.readNextStartElement();
|
||||||
if (reader.name() == QLatin1String("v")) {
|
if (reader.name() == QLatin1String("v")) {
|
||||||
QString value = reader.readElementText();
|
QString value = reader.readElementText();
|
||||||
QSharedPointer<XlsxCellData> data(new XlsxCellData(value.toInt() ? true : false, XlsxCellData::Boolean, format));
|
QSharedPointer<Cell> data(new Cell(value.toInt() ? true : false, Cell::Boolean, format));
|
||||||
cellTable[pos.x()][pos.y()] = data;
|
cellTable[pos.x()][pos.y()] = data;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1132,8 +1134,8 @@ void WorksheetPrivate::readSheetData(XmlStreamReader &reader)
|
|||||||
reader.readNextStartElement();
|
reader.readNextStartElement();
|
||||||
if (reader.name() == QLatin1String("v")) {
|
if (reader.name() == QLatin1String("v")) {
|
||||||
QString value = reader.readElementText();
|
QString value = reader.readElementText();
|
||||||
XlsxCellData *data = new XlsxCellData(value ,XlsxCellData::Number, format);
|
Cell *data = new Cell(value ,Cell::Number, format);
|
||||||
cellTable[pos.x()][pos.y()] = QSharedPointer<XlsxCellData>(data);
|
cellTable[pos.x()][pos.y()] = QSharedPointer<Cell>(data);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,6 +26,7 @@
|
|||||||
#define XLSXWORKSHEET_P_H
|
#define XLSXWORKSHEET_P_H
|
||||||
#include "xlsxglobal.h"
|
#include "xlsxglobal.h"
|
||||||
#include "xlsxworksheet.h"
|
#include "xlsxworksheet.h"
|
||||||
|
#include "xlsxcell.h"
|
||||||
|
|
||||||
#include <QImage>
|
#include <QImage>
|
||||||
#include <QSharedPointer>
|
#include <QSharedPointer>
|
||||||
@@ -35,29 +36,6 @@ namespace QXlsx {
|
|||||||
class XmlStreamWriter;
|
class XmlStreamWriter;
|
||||||
class XmlStreamReader;
|
class XmlStreamReader;
|
||||||
|
|
||||||
struct XlsxCellData
|
|
||||||
{
|
|
||||||
enum CellDataType {
|
|
||||||
Blank,
|
|
||||||
String,
|
|
||||||
Number,
|
|
||||||
Formula,
|
|
||||||
ArrayFormula,
|
|
||||||
Boolean,
|
|
||||||
DateTime
|
|
||||||
};
|
|
||||||
XlsxCellData(const QVariant &data=QVariant(), CellDataType type=Blank, Format *format=0) :
|
|
||||||
value(data), dataType(type), format(format)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant value;
|
|
||||||
QString formula;
|
|
||||||
CellDataType dataType;
|
|
||||||
Format *format;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct XlsxUrlData
|
struct XlsxUrlData
|
||||||
{
|
{
|
||||||
XlsxUrlData(int linkType=1, const QString &url=QString(), const QString &location=QString(), const QString &tip=QString()) :
|
XlsxUrlData(int linkType=1, const QString &url=QString(), const QString &location=QString(), const QString &tip=QString()) :
|
||||||
@@ -187,7 +165,7 @@ public:
|
|||||||
QString generateDimensionString();
|
QString generateDimensionString();
|
||||||
void calculateSpans();
|
void calculateSpans();
|
||||||
void writeSheetData(XmlStreamWriter &writer);
|
void writeSheetData(XmlStreamWriter &writer);
|
||||||
void writeCellData(XmlStreamWriter &writer, int row, int col, QSharedPointer<XlsxCellData> cell);
|
void writeCellData(XmlStreamWriter &writer, int row, int col, QSharedPointer<Cell> cell);
|
||||||
void writeMergeCells(XmlStreamWriter &writer);
|
void writeMergeCells(XmlStreamWriter &writer);
|
||||||
void writeHyperlinks(XmlStreamWriter &writer);
|
void writeHyperlinks(XmlStreamWriter &writer);
|
||||||
void writeDrawings(XmlStreamWriter &writer);
|
void writeDrawings(XmlStreamWriter &writer);
|
||||||
@@ -202,7 +180,7 @@ public:
|
|||||||
|
|
||||||
Workbook *workbook;
|
Workbook *workbook;
|
||||||
Drawing *drawing;
|
Drawing *drawing;
|
||||||
QMap<int, QMap<int, QSharedPointer<XlsxCellData> > > cellTable;
|
QMap<int, QMap<int, QSharedPointer<Cell> > > cellTable;
|
||||||
QMap<int, QMap<int, QString> > comments;
|
QMap<int, QMap<int, QString> > comments;
|
||||||
QMap<int, QMap<int, XlsxUrlData *> > urlTable;
|
QMap<int, QMap<int, XlsxUrlData *> > urlTable;
|
||||||
QList<XlsxCellRange> merges;
|
QList<XlsxCellRange> merges;
|
||||||
|
|||||||
Reference in New Issue
Block a user