API refactoring: write*() return boolean instead of integer
This commit is contained in:
@@ -388,7 +388,7 @@ Document::Document(QIODevice *device, QObject *parent) :
|
||||
|
||||
Write \a value to cell \a row_column with the \a format.
|
||||
*/
|
||||
int Document::write(const QString &row_column, const QVariant &value, const Format &format)
|
||||
bool Document::write(const QString &row_column, const QVariant &value, const Format &format)
|
||||
{
|
||||
return currentWorksheet()->write(row_column, value, format);
|
||||
}
|
||||
@@ -396,7 +396,7 @@ int Document::write(const QString &row_column, const QVariant &value, const Form
|
||||
/*!
|
||||
* Write \a value to cell (\a row, \a col) with the \a format.
|
||||
*/
|
||||
int Document::write(int row, int col, const QVariant &value, const Format &format)
|
||||
bool Document::write(int row, int col, const QVariant &value, const Format &format)
|
||||
{
|
||||
return currentWorksheet()->write(row, col, value, format);
|
||||
}
|
||||
@@ -443,7 +443,7 @@ Chart *Document::insertChart(int row, int col, const QSize &size)
|
||||
|
||||
\note All cells except the top-left one will be cleared.
|
||||
*/
|
||||
int Document::mergeCells(const CellRange &range, const Format &format)
|
||||
bool Document::mergeCells(const CellRange &range, const Format &format)
|
||||
{
|
||||
return currentWorksheet()->mergeCells(range, format);
|
||||
}
|
||||
@@ -455,7 +455,7 @@ int Document::mergeCells(const CellRange &range, const Format &format)
|
||||
|
||||
\note All cells except the top-left one will be cleared.
|
||||
*/
|
||||
int Document::mergeCells(const QString &range, const Format &format)
|
||||
bool Document::mergeCells(const QString &range, const Format &format)
|
||||
{
|
||||
return currentWorksheet()->mergeCells(range, format);
|
||||
}
|
||||
@@ -463,7 +463,7 @@ int Document::mergeCells(const QString &range, const Format &format)
|
||||
/*!
|
||||
Unmerge the cells in the \a range.
|
||||
*/
|
||||
int Document::unmergeCells(const QString &range)
|
||||
bool Document::unmergeCells(const QString &range)
|
||||
{
|
||||
return currentWorksheet()->unmergeCells(range);
|
||||
}
|
||||
@@ -471,7 +471,7 @@ int Document::unmergeCells(const QString &range)
|
||||
/*!
|
||||
Unmerge the cells in the \a range.
|
||||
*/
|
||||
int Document::unmergeCells(const CellRange &range)
|
||||
bool Document::unmergeCells(const CellRange &range)
|
||||
{
|
||||
return currentWorksheet()->unmergeCells(range);
|
||||
}
|
||||
@@ -656,19 +656,6 @@ AbstractSheet *Document::sheet(const QString &sheetName) const
|
||||
return d->workbook->sheet(sheetNames().indexOf(sheetName));
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns the worksheet object named \a sheetName.
|
||||
* If the type of sheet is not AbstractSheet::ST_WorkSheet, then 0 will be returned.
|
||||
*/
|
||||
Worksheet *Document::worksheet(const QString &sheetName) const
|
||||
{
|
||||
AbstractSheet *st = sheet(sheetName);
|
||||
if (st && st->sheetType() == AbstractSheet::ST_WorkSheet)
|
||||
return static_cast<Worksheet *>(st);
|
||||
else
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Creates and append an document with name \a name.
|
||||
* Return true if success.
|
||||
|
||||
@@ -55,16 +55,16 @@ public:
|
||||
Document(QIODevice *device, QObject *parent=0);
|
||||
~Document();
|
||||
|
||||
int write(const QString &cell, const QVariant &value, const Format &format=Format());
|
||||
int write(int row, int col, const QVariant &value, const Format &format=Format());
|
||||
bool write(const QString &cell, const QVariant &value, const Format &format=Format());
|
||||
bool write(int row, int col, const QVariant &value, const Format &format=Format());
|
||||
QVariant read(const QString &cell) const;
|
||||
QVariant read(int row, int col) const;
|
||||
bool insertImage(int row, int col, const QImage &image);
|
||||
Chart *insertChart(int row, int col, const QSize &size);
|
||||
int mergeCells(const CellRange &range, const Format &format=Format());
|
||||
int mergeCells(const QString &range, const Format &format=Format());
|
||||
int unmergeCells(const CellRange &range);
|
||||
int unmergeCells(const QString &range);
|
||||
bool mergeCells(const CellRange &range, const Format &format=Format());
|
||||
bool mergeCells(const QString &range, const Format &format=Format());
|
||||
bool unmergeCells(const CellRange &range);
|
||||
bool unmergeCells(const QString &range);
|
||||
bool setRow(int row, double height, const Format &format=Format(), bool hidden=false);
|
||||
bool setColumn(int colFirst, int colLast, double width, const Format &format=Format(), bool hidden=false);
|
||||
bool setColumn(const QString &colFirst, const QString &colLast, double width, const Format &format=Format(), bool hidden=false);
|
||||
@@ -96,7 +96,6 @@ public:
|
||||
Workbook *workbook() const;
|
||||
AbstractSheet *sheet(const QString &sheetName) const;
|
||||
AbstractSheet *currentSheet() const;
|
||||
Worksheet *worksheet(const QString &sheetName) const;
|
||||
Worksheet *currentWorksheet() const;
|
||||
|
||||
bool save() const;
|
||||
|
||||
+73
-86
@@ -415,14 +415,14 @@ void Worksheet::setWhiteSpaceVisible(bool visible)
|
||||
* Write \a value to cell (\a row, \a column) with the \a format.
|
||||
* Both \a row and \a column are all 1-indexed value.
|
||||
*/
|
||||
int Worksheet::write(int row, int column, const QVariant &value, const Format &format)
|
||||
bool Worksheet::write(int row, int column, const QVariant &value, const Format &format)
|
||||
{
|
||||
Q_D(Worksheet);
|
||||
int ret = 0;
|
||||
|
||||
if (d->checkDimensions(row, column))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
bool ret = true;
|
||||
if (value.isNull()) {
|
||||
//Blank
|
||||
ret = writeBlank(row, column, format);
|
||||
@@ -471,7 +471,7 @@ int Worksheet::write(int row, int column, const QVariant &value, const Format &f
|
||||
}
|
||||
} else {
|
||||
//Wrong type
|
||||
return -1;
|
||||
return false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
@@ -482,12 +482,12 @@ int Worksheet::write(int row, int column, const QVariant &value, const Format &f
|
||||
* Write \a value to cell \a row_column with the \a format.
|
||||
* Both row and column are all 1-indexed value.
|
||||
*/
|
||||
int Worksheet::write(const QString &row_column, const QVariant &value, const Format &format)
|
||||
bool Worksheet::write(const QString &row_column, const QVariant &value, const Format &format)
|
||||
{
|
||||
//convert the "A1" notation to row/column notation
|
||||
QPoint pos = xl_cell_to_rowcol(row_column);
|
||||
if (pos == QPoint(-1, -1))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
return write(pos.x(), pos.y(), value, format);
|
||||
}
|
||||
@@ -570,12 +570,12 @@ Format WorksheetPrivate::cellFormat(int row, int col) const
|
||||
\overload
|
||||
Write string \a value to the cell \a row_column with the \a format
|
||||
*/
|
||||
int Worksheet::writeString(const QString &row_column, const RichString &value, const Format &format)
|
||||
bool Worksheet::writeString(const QString &row_column, const RichString &value, const Format &format)
|
||||
{
|
||||
//convert the "A1" notation to row/column notation
|
||||
QPoint pos = xl_cell_to_rowcol(row_column);
|
||||
if (pos == QPoint(-1, -1))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
return writeString(pos.x(), pos.y(), value, format);
|
||||
}
|
||||
@@ -583,13 +583,12 @@ int Worksheet::writeString(const QString &row_column, const RichString &value, c
|
||||
/*!
|
||||
Write string \a value to the cell (\a row, \a column) with the \a format
|
||||
*/
|
||||
int Worksheet::writeString(int row, int column, const RichString &value, const Format &format)
|
||||
bool Worksheet::writeString(int row, int column, const RichString &value, const Format &format)
|
||||
{
|
||||
Q_D(Worksheet);
|
||||
int error = 0;
|
||||
// QString content = value.toPlainString();
|
||||
if (d->checkDimensions(row, column))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
// if (content.size() > d->xls_strmax) {
|
||||
// content = content.left(d->xls_strmax);
|
||||
@@ -604,19 +603,19 @@ int Worksheet::writeString(int row, int column, const RichString &value, const F
|
||||
QSharedPointer<Cell> cell = QSharedPointer<Cell>(new Cell(value.toPlainString(), Cell::String, fmt, this));
|
||||
cell->d_ptr->richString = value;
|
||||
d->cellTable[row][column] = cell;
|
||||
return error;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
Write string \a value to the cell \a row_column with the \a format
|
||||
*/
|
||||
int Worksheet::writeString(const QString &row_column, const QString &value, const Format &format)
|
||||
bool Worksheet::writeString(const QString &row_column, const QString &value, const Format &format)
|
||||
{
|
||||
//convert the "A1" notation to row/column notation
|
||||
QPoint pos = xl_cell_to_rowcol(row_column);
|
||||
if (pos == QPoint(-1, -1))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
return writeString(pos.x(), pos.y(), value, format);
|
||||
}
|
||||
@@ -626,11 +625,11 @@ int Worksheet::writeString(const QString &row_column, const QString &value, cons
|
||||
|
||||
Write string \a value to the cell (\a row, \a column) with the \a format
|
||||
*/
|
||||
int Worksheet::writeString(int row, int column, const QString &value, const Format &format)
|
||||
bool Worksheet::writeString(int row, int column, const QString &value, const Format &format)
|
||||
{
|
||||
Q_D(Worksheet);
|
||||
if (d->checkDimensions(row, column))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
RichString rs;
|
||||
if (Qt::mightBeRichText(value) && d->workbook->isHtmlToRichStringEnabled())
|
||||
@@ -645,12 +644,12 @@ int Worksheet::writeString(int row, int column, const QString &value, const Form
|
||||
\overload
|
||||
Write string \a value to the cell \a row_column with the \a format
|
||||
*/
|
||||
int Worksheet::writeInlineString(const QString &row_column, const QString &value, const Format &format)
|
||||
bool Worksheet::writeInlineString(const QString &row_column, const QString &value, const Format &format)
|
||||
{
|
||||
//convert the "A1" notation to row/column notation
|
||||
QPoint pos = xl_cell_to_rowcol(row_column);
|
||||
if (pos == QPoint(-1, -1))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
return writeInlineString(pos.x(), pos.y(), value, format);
|
||||
}
|
||||
@@ -658,13 +657,13 @@ int Worksheet::writeInlineString(const QString &row_column, const QString &value
|
||||
/*!
|
||||
Write string \a value to the cell (\a row, \a column) with the \a format
|
||||
*/
|
||||
int Worksheet::writeInlineString(int row, int column, const QString &value, const Format &format)
|
||||
bool Worksheet::writeInlineString(int row, int column, const QString &value, const Format &format)
|
||||
{
|
||||
Q_D(Worksheet);
|
||||
int error = 0;
|
||||
QString content = value;
|
||||
if (d->checkDimensions(row, column))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
if (value.size() > XLSX_STRING_MAX) {
|
||||
content = value.left(XLSX_STRING_MAX);
|
||||
@@ -674,19 +673,19 @@ int Worksheet::writeInlineString(int row, int column, const QString &value, cons
|
||||
Format fmt = format.isValid() ? format : d->cellFormat(row, column);
|
||||
d->workbook->styles()->addXfFormat(fmt);
|
||||
d->cellTable[row][column] = QSharedPointer<Cell>(new Cell(value, Cell::InlineString, fmt, this));
|
||||
return error;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
Write numeric \a value to the cell \a row_column with the \a format
|
||||
*/
|
||||
int Worksheet::writeNumeric(const QString &row_column, double value, const Format &format)
|
||||
bool Worksheet::writeNumeric(const QString &row_column, double value, const Format &format)
|
||||
{
|
||||
//convert the "A1" notation to row/column notation
|
||||
QPoint pos = xl_cell_to_rowcol(row_column);
|
||||
if (pos == QPoint(-1, -1))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
return writeNumeric(pos.x(), pos.y(), value, format);
|
||||
}
|
||||
@@ -694,28 +693,28 @@ int Worksheet::writeNumeric(const QString &row_column, double value, const Forma
|
||||
/*!
|
||||
Write numeric \a value to the cell (\a row, \a column) with the \a format
|
||||
*/
|
||||
int Worksheet::writeNumeric(int row, int column, double value, const Format &format)
|
||||
bool Worksheet::writeNumeric(int row, int column, double value, const Format &format)
|
||||
{
|
||||
Q_D(Worksheet);
|
||||
if (d->checkDimensions(row, column))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
Format fmt = format.isValid() ? format : d->cellFormat(row, column);
|
||||
d->workbook->styles()->addXfFormat(fmt);
|
||||
d->cellTable[row][column] = QSharedPointer<Cell>(new Cell(value, Cell::Numeric, fmt, this));
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
Write \a formula to the cell \a row_column with the \a format and \a result.
|
||||
*/
|
||||
int Worksheet::writeFormula(const QString &row_column, const QString &formula, const Format &format, double result)
|
||||
bool Worksheet::writeFormula(const QString &row_column, const QString &formula, const Format &format, double result)
|
||||
{
|
||||
//convert the "A1" notation to row/column notation
|
||||
QPoint pos = xl_cell_to_rowcol(row_column);
|
||||
if (pos == QPoint(-1, -1))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
return writeFormula(pos.x(), pos.y(), formula, format, result);
|
||||
}
|
||||
@@ -723,13 +722,12 @@ int Worksheet::writeFormula(const QString &row_column, const QString &formula, c
|
||||
/*!
|
||||
Write \a formula to the cell (\a row, \a column) with the \a format and \a result.
|
||||
*/
|
||||
int Worksheet::writeFormula(int row, int column, const QString &formula, const Format &format, double result)
|
||||
bool Worksheet::writeFormula(int row, int column, const QString &formula, const Format &format, double result)
|
||||
{
|
||||
Q_D(Worksheet);
|
||||
int error = 0;
|
||||
QString _formula = formula;
|
||||
if (d->checkDimensions(row, column))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
//Remove the formula '=' sign if exists
|
||||
if (_formula.startsWith(QLatin1String("=")))
|
||||
@@ -741,21 +739,20 @@ int Worksheet::writeFormula(int row, int column, const QString &formula, const F
|
||||
data->d_ptr->formula = _formula;
|
||||
d->cellTable[row][column] = QSharedPointer<Cell>(data);
|
||||
|
||||
return error;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
Write \a formula to the \a range with the \a format
|
||||
*/
|
||||
int Worksheet::writeArrayFormula(const CellRange &range, const QString &formula, const Format &format)
|
||||
bool Worksheet::writeArrayFormula(const CellRange &range, const QString &formula, const Format &format)
|
||||
{
|
||||
Q_D(Worksheet);
|
||||
int error = 0;
|
||||
|
||||
if (d->checkDimensions(range.firstRow(), range.firstColumn()))
|
||||
return -1;
|
||||
return false;
|
||||
if (d->checkDimensions(range.lastRow(), range.lastColumn()))
|
||||
return -1;
|
||||
return false;
|
||||
QString _formula = formula;
|
||||
//Remove the formula "{=" and "}" sign if exists
|
||||
if (_formula.startsWith(QLatin1String("{=")))
|
||||
@@ -778,14 +775,14 @@ int Worksheet::writeArrayFormula(const CellRange &range, const QString &formula,
|
||||
}
|
||||
}
|
||||
|
||||
return error;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
Write \a formula to the \a range with the \a format
|
||||
*/
|
||||
int Worksheet::writeArrayFormula(const QString &range, const QString &formula, const Format &format)
|
||||
bool Worksheet::writeArrayFormula(const QString &range, const QString &formula, const Format &format)
|
||||
{
|
||||
return writeArrayFormula(CellRange(range), formula, format);
|
||||
}
|
||||
@@ -794,12 +791,12 @@ int Worksheet::writeArrayFormula(const QString &range, const QString &formula, c
|
||||
\overload
|
||||
Write a empty cell \a row_column with the \a format
|
||||
*/
|
||||
int Worksheet::writeBlank(const QString &row_column, const Format &format)
|
||||
bool Worksheet::writeBlank(const QString &row_column, const Format &format)
|
||||
{
|
||||
//convert the "A1" notation to row/column notation
|
||||
QPoint pos = xl_cell_to_rowcol(row_column);
|
||||
if (pos == QPoint(-1, -1))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
return writeBlank(pos.x(), pos.y(), format);
|
||||
}
|
||||
@@ -807,29 +804,29 @@ int Worksheet::writeBlank(const QString &row_column, const Format &format)
|
||||
/*!
|
||||
Write a empty cell (\a row, \a column) with the \a format
|
||||
*/
|
||||
int Worksheet::writeBlank(int row, int column, const Format &format)
|
||||
bool Worksheet::writeBlank(int row, int column, const Format &format)
|
||||
{
|
||||
Q_D(Worksheet);
|
||||
if (d->checkDimensions(row, column))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
Format fmt = format.isValid() ? format : d->cellFormat(row, column);
|
||||
d->workbook->styles()->addXfFormat(fmt);
|
||||
|
||||
d->cellTable[row][column] = QSharedPointer<Cell>(new Cell(QVariant(), Cell::Blank, fmt, this));
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
/*!
|
||||
\overload
|
||||
Write a bool \a value to the cell \a row_column with the \a format
|
||||
*/
|
||||
int Worksheet::writeBool(const QString &row_column, bool value, const Format &format)
|
||||
bool Worksheet::writeBool(const QString &row_column, bool value, const Format &format)
|
||||
{
|
||||
//convert the "A1" notation to row/column notation
|
||||
QPoint pos = xl_cell_to_rowcol(row_column);
|
||||
if (pos == QPoint(-1, -1))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
return writeBool(pos.x(), pos.y(), value, format);
|
||||
}
|
||||
@@ -837,28 +834,28 @@ int Worksheet::writeBool(const QString &row_column, bool value, const Format &fo
|
||||
/*!
|
||||
Write a bool \a value to the cell (\a row, \a column) with the \a format
|
||||
*/
|
||||
int Worksheet::writeBool(int row, int column, bool value, const Format &format)
|
||||
bool Worksheet::writeBool(int row, int column, bool value, const Format &format)
|
||||
{
|
||||
Q_D(Worksheet);
|
||||
if (d->checkDimensions(row, column))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
Format fmt = format.isValid() ? format : d->cellFormat(row, column);
|
||||
d->workbook->styles()->addXfFormat(fmt);
|
||||
d->cellTable[row][column] = QSharedPointer<Cell>(new Cell(value, Cell::Boolean, fmt, this));
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
/*!
|
||||
\overload
|
||||
Write a QDateTime \a dt to the cell \a row_column with the \a format
|
||||
*/
|
||||
int Worksheet::writeDateTime(const QString &row_column, const QDateTime &dt, const Format &format)
|
||||
bool Worksheet::writeDateTime(const QString &row_column, const QDateTime &dt, const Format &format)
|
||||
{
|
||||
//convert the "A1" notation to row/column notation
|
||||
QPoint pos = xl_cell_to_rowcol(row_column);
|
||||
if (pos == QPoint(-1, -1))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
return writeDateTime(pos.x(), pos.y(), dt, format);
|
||||
}
|
||||
@@ -866,11 +863,11 @@ int Worksheet::writeDateTime(const QString &row_column, const QDateTime &dt, con
|
||||
/*!
|
||||
Write a QDateTime \a dt to the cell (\a row, \a column) with the \a format
|
||||
*/
|
||||
int Worksheet::writeDateTime(int row, int column, const QDateTime &dt, const Format &format)
|
||||
bool Worksheet::writeDateTime(int row, int column, const QDateTime &dt, const Format &format)
|
||||
{
|
||||
Q_D(Worksheet);
|
||||
if (d->checkDimensions(row, column))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
Format fmt = format.isValid() ? format : d->cellFormat(row, column);
|
||||
if (!fmt.isValid() || !fmt.isDateTimeFormat())
|
||||
@@ -881,19 +878,19 @@ int Worksheet::writeDateTime(int row, int column, const QDateTime &dt, const For
|
||||
|
||||
d->cellTable[row][column] = QSharedPointer<Cell>(new Cell(value, Cell::Numeric, fmt, this));
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
Write a QTime \a t to the cell \a row_column with the \a format
|
||||
*/
|
||||
int Worksheet::writeTime(const QString &row_column, const QTime &t, const Format &format)
|
||||
bool Worksheet::writeTime(const QString &row_column, const QTime &t, const Format &format)
|
||||
{
|
||||
//convert the "A1" notation to row/column notation
|
||||
QPoint pos = xl_cell_to_rowcol(row_column);
|
||||
if (pos == QPoint(-1, -1))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
return writeTime(pos.x(), pos.y(), t, format);
|
||||
}
|
||||
@@ -901,11 +898,11 @@ int Worksheet::writeTime(const QString &row_column, const QTime &t, const Format
|
||||
/*!
|
||||
Write a QTime \a t to the cell (\a row, \a column) with the \a format
|
||||
*/
|
||||
int Worksheet::writeTime(int row, int column, const QTime &t, const Format &format)
|
||||
bool Worksheet::writeTime(int row, int column, const QTime &t, const Format &format)
|
||||
{
|
||||
Q_D(Worksheet);
|
||||
if (d->checkDimensions(row, column))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
Format fmt = format.isValid() ? format : d->cellFormat(row, column);
|
||||
if (!fmt.isValid() || !fmt.isDateTimeFormat())
|
||||
@@ -914,19 +911,19 @@ int Worksheet::writeTime(int row, int column, const QTime &t, const Format &form
|
||||
|
||||
d->cellTable[row][column] = QSharedPointer<Cell>(new Cell(timeToNumber(t), Cell::Numeric, fmt, this));
|
||||
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
Write a QUrl \a url to the cell \a row_column with the given \a format \a display and \a tip
|
||||
*/
|
||||
int Worksheet::writeHyperlink(const QString &row_column, const QUrl &url, const Format &format, const QString &display, const QString &tip)
|
||||
bool Worksheet::writeHyperlink(const QString &row_column, const QUrl &url, const Format &format, const QString &display, const QString &tip)
|
||||
{
|
||||
//convert the "A1" notation to row/column notation
|
||||
QPoint pos = xl_cell_to_rowcol(row_column);
|
||||
if (pos == QPoint(-1, -1))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
return writeHyperlink(pos.x(), pos.y(), url, format, display, tip);
|
||||
}
|
||||
@@ -934,11 +931,11 @@ int Worksheet::writeHyperlink(const QString &row_column, const QUrl &url, const
|
||||
/*!
|
||||
Write a QUrl \a url to the cell (\a row, \a column) with the given \a format \a display and \a tip.
|
||||
*/
|
||||
int Worksheet::writeHyperlink(int row, int column, const QUrl &url, const Format &format, const QString &display, const QString &tip)
|
||||
bool Worksheet::writeHyperlink(int row, int column, const QUrl &url, const Format &format, const QString &display, const QString &tip)
|
||||
{
|
||||
Q_D(Worksheet);
|
||||
if (d->checkDimensions(row, column))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
int error = 0;
|
||||
|
||||
@@ -982,7 +979,7 @@ int Worksheet::writeHyperlink(int row, int column, const QUrl &url, const Format
|
||||
//Store the hyperlink data in a separate table
|
||||
d->urlTable[row][column] = QSharedPointer<XlsxHyperlinkData>(new XlsxHyperlinkData(XlsxHyperlinkData::External, urlString, locationString, QString(), tip));
|
||||
|
||||
return error;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1047,16 +1044,6 @@ bool Worksheet::insertImage(int row, int column, const QImage &image)
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \overload
|
||||
* Insert an \a image at the position \a row, \a column with the given
|
||||
* \a offset \a xScale and \a yScale.
|
||||
*/
|
||||
int Worksheet::insertImage(int row, int column, const QImage &image, const QPointF & /*offset*/, double /*xScale*/, double /*yScale*/)
|
||||
{
|
||||
return insertImage(row, column, image);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Creates an chart with the given \a size and insert
|
||||
* at the position \a row, \a column.
|
||||
@@ -1091,14 +1078,14 @@ Chart *Worksheet::insertChart(int row, int column, const QSize &size)
|
||||
|
||||
\note All cells except the top-left one will be cleared.
|
||||
*/
|
||||
int Worksheet::mergeCells(const CellRange &range, const Format &format)
|
||||
bool Worksheet::mergeCells(const CellRange &range, const Format &format)
|
||||
{
|
||||
Q_D(Worksheet);
|
||||
if (range.rowCount() < 2 && range.columnCount() < 2)
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
if (d->checkDimensions(range.firstRow(), range.firstColumn()))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
if (format.isValid())
|
||||
d->workbook->styles()->addXfFormat(format);
|
||||
@@ -1120,7 +1107,7 @@ int Worksheet::mergeCells(const CellRange &range, const Format &format)
|
||||
}
|
||||
|
||||
d->merges.append(range);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
@@ -1130,16 +1117,16 @@ int Worksheet::mergeCells(const CellRange &range, const Format &format)
|
||||
|
||||
\note All cells except the top-left one will be cleared.
|
||||
*/
|
||||
int Worksheet::mergeCells(const QString &range, const Format &format)
|
||||
bool Worksheet::mergeCells(const QString &range, const Format &format)
|
||||
{
|
||||
QStringList cells = range.split(QLatin1Char(':'));
|
||||
if (cells.size() != 2)
|
||||
return -1;
|
||||
return false;
|
||||
QPoint cell1 = xl_cell_to_rowcol(cells[0]);
|
||||
QPoint cell2 = xl_cell_to_rowcol(cells[1]);
|
||||
|
||||
if (cell1 == QPoint(-1,-1) || cell2 == QPoint(-1, -1))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
return mergeCells(CellRange(cell1.x(), cell1.y(), cell2.x(), cell2.y()), format);
|
||||
}
|
||||
@@ -1147,30 +1134,30 @@ int Worksheet::mergeCells(const QString &range, const Format &format)
|
||||
/*!
|
||||
Unmerge the cells in the \a range.
|
||||
*/
|
||||
int Worksheet::unmergeCells(const CellRange &range)
|
||||
bool Worksheet::unmergeCells(const CellRange &range)
|
||||
{
|
||||
Q_D(Worksheet);
|
||||
if (!d->merges.contains(range))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
d->merges.removeOne(range);
|
||||
return 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\overload
|
||||
Unmerge the cells in the \a range.
|
||||
*/
|
||||
int Worksheet::unmergeCells(const QString &range)
|
||||
bool Worksheet::unmergeCells(const QString &range)
|
||||
{
|
||||
QStringList cells = range.split(QLatin1Char(':'));
|
||||
if (cells.size() != 2)
|
||||
return -1;
|
||||
return false;
|
||||
QPoint cell1 = xl_cell_to_rowcol(cells[0]);
|
||||
QPoint cell2 = xl_cell_to_rowcol(cells[1]);
|
||||
|
||||
if (cell1 == QPoint(-1,-1) || cell2 == QPoint(-1, -1))
|
||||
return -1;
|
||||
return false;
|
||||
|
||||
return unmergeCells(CellRange(cell1.x(), cell1.y(), cell2.x(), cell2.y()));
|
||||
}
|
||||
|
||||
+28
-29
@@ -56,33 +56,33 @@ class Q_XLSX_EXPORT Worksheet : public AbstractSheet
|
||||
{
|
||||
Q_DECLARE_PRIVATE(Worksheet)
|
||||
public:
|
||||
int write(const QString &row_column, const QVariant &value, const Format &format=Format());
|
||||
int write(int row, int column, const QVariant &value, const Format &format=Format());
|
||||
bool write(const QString &row_column, const QVariant &value, const Format &format=Format());
|
||||
bool write(int row, int column, const QVariant &value, const Format &format=Format());
|
||||
QVariant read(const QString &row_column) const;
|
||||
QVariant read(int row, int column) const;
|
||||
int writeString(const QString &row_column, const QString &value, const Format &format=Format());
|
||||
int writeString(int row, int column, const QString &value, const Format &format=Format());
|
||||
int writeString(const QString &row_column, const RichString &value, const Format &format=Format());
|
||||
int writeString(int row, int column, const RichString &value, const Format &format=Format());
|
||||
int writeInlineString(const QString &row_column, const QString &value, const Format &format=Format());
|
||||
int writeInlineString(int row, int column, const QString &value, const Format &format=Format());
|
||||
int writeNumeric(const QString &row_column, double value, const Format &format=Format());
|
||||
int writeNumeric(int row, int column, double value, const Format &format=Format());
|
||||
int writeFormula(const QString &row_column, const QString &formula, const Format &format=Format(), double result=0);
|
||||
int writeFormula(int row, int column, const QString &formula, const Format &format=Format(), double result=0);
|
||||
int writeArrayFormula(const QString &range, const QString &formula, const Format &format=Format());
|
||||
int writeArrayFormula(const CellRange &range, const QString &formula, const Format &format=Format());
|
||||
int writeBlank(const QString &row_column, const Format &format=Format());
|
||||
int writeBlank(int row, int column, const Format &format=Format());
|
||||
int writeBool(const QString &row_column, bool value, const Format &format=Format());
|
||||
int writeBool(int row, int column, bool value, const Format &format=Format());
|
||||
int writeDateTime(const QString &row_column, const QDateTime& dt, const Format &format=Format());
|
||||
int writeDateTime(int row, int column, const QDateTime& dt, const Format &format=Format());
|
||||
int writeTime(const QString &row_column, const QTime& t, const Format &format=Format());
|
||||
int writeTime(int row, int column, const QTime& t, const Format &format=Format());
|
||||
bool writeString(const QString &row_column, const QString &value, const Format &format=Format());
|
||||
bool writeString(int row, int column, const QString &value, const Format &format=Format());
|
||||
bool writeString(const QString &row_column, const RichString &value, const Format &format=Format());
|
||||
bool writeString(int row, int column, const RichString &value, const Format &format=Format());
|
||||
bool writeInlineString(const QString &row_column, const QString &value, const Format &format=Format());
|
||||
bool writeInlineString(int row, int column, const QString &value, const Format &format=Format());
|
||||
bool writeNumeric(const QString &row_column, double value, const Format &format=Format());
|
||||
bool writeNumeric(int row, int column, double value, const Format &format=Format());
|
||||
bool writeFormula(const QString &row_column, const QString &formula, const Format &format=Format(), double result=0);
|
||||
bool writeFormula(int row, int column, const QString &formula, const Format &format=Format(), double result=0);
|
||||
bool writeArrayFormula(const QString &range, const QString &formula, const Format &format=Format());
|
||||
bool writeArrayFormula(const CellRange &range, const QString &formula, const Format &format=Format());
|
||||
bool writeBlank(const QString &row_column, const Format &format=Format());
|
||||
bool writeBlank(int row, int column, const Format &format=Format());
|
||||
bool writeBool(const QString &row_column, bool value, const Format &format=Format());
|
||||
bool writeBool(int row, int column, bool value, const Format &format=Format());
|
||||
bool writeDateTime(const QString &row_column, const QDateTime& dt, const Format &format=Format());
|
||||
bool writeDateTime(int row, int column, const QDateTime& dt, const Format &format=Format());
|
||||
bool writeTime(const QString &row_column, const QTime& t, const Format &format=Format());
|
||||
bool writeTime(int row, int column, const QTime& t, const Format &format=Format());
|
||||
|
||||
int writeHyperlink(const QString &row_column, const QUrl &url, const Format &format=Format(), const QString &display=QString(), const QString &tip=QString());
|
||||
int writeHyperlink(int row, int column, const QUrl &url, const Format &format=Format(), const QString &display=QString(), const QString &tip=QString());
|
||||
bool writeHyperlink(const QString &row_column, const QUrl &url, const Format &format=Format(), const QString &display=QString(), const QString &tip=QString());
|
||||
bool writeHyperlink(int row, int column, const QUrl &url, const Format &format=Format(), const QString &display=QString(), const QString &tip=QString());
|
||||
|
||||
bool addDataValidation(const DataValidation &validation);
|
||||
bool addConditionalFormatting(const ConditionalFormatting &cf);
|
||||
@@ -91,13 +91,12 @@ public:
|
||||
Cell *cellAt(int row, int column) const;
|
||||
|
||||
bool insertImage(int row, int column, const QImage &image);
|
||||
Q_DECL_DEPRECATED int insertImage(int row, int column, const QImage &image, const QPointF &offset, double xScale=1, double yScale=1);
|
||||
Chart *insertChart(int row, int column, const QSize &size);
|
||||
|
||||
int mergeCells(const QString &range, const Format &format=Format());
|
||||
int mergeCells(const CellRange &range, const Format &format=Format());
|
||||
int unmergeCells(const QString &range);
|
||||
int unmergeCells(const CellRange &range);
|
||||
bool mergeCells(const QString &range, const Format &format=Format());
|
||||
bool mergeCells(const CellRange &range, const Format &format=Format());
|
||||
bool unmergeCells(const QString &range);
|
||||
bool unmergeCells(const CellRange &range);
|
||||
QList<CellRange> mergedCells() const;
|
||||
|
||||
bool setRow(int row, double height, const Format &format=Format(), bool hidden=false);
|
||||
|
||||
Reference in New Issue
Block a user