Add new member QXlsx::Document::cellAt()
This commit is contained in:
@@ -52,24 +52,36 @@ Cell::Cell(const QVariant &data, DataType type, Format *format) :
|
||||
d_ptr->format = format;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Return the dataType of this Cell
|
||||
*/
|
||||
Cell::DataType Cell::dataType() const
|
||||
{
|
||||
Q_D(const Cell);
|
||||
return d->dataType;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Return the data content of this Cell
|
||||
*/
|
||||
QVariant Cell::value() const
|
||||
{
|
||||
Q_D(const Cell);
|
||||
return d->value;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Return the style used by this Cell. If no style used, 0 will be returned.
|
||||
*/
|
||||
Format *Cell::format() const
|
||||
{
|
||||
Q_D(const Cell);
|
||||
return d->format;
|
||||
}
|
||||
|
||||
/*!
|
||||
* Return the formula contents if the dataType is Formula
|
||||
*/
|
||||
QString Cell::formula() const
|
||||
{
|
||||
Q_D(const Cell);
|
||||
|
||||
@@ -182,6 +182,22 @@ bool Document::setColumn(int colFirst, int colLast, double width, Format *format
|
||||
return currentWorksheet()->setColumn(colFirst, colLast, width, format, hidden);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns a Cell object based on the given \a pos.
|
||||
*/
|
||||
Cell *Document::cellAt(const QString &pos) const
|
||||
{
|
||||
return currentWorksheet()->cellAt(pos);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns a Cell object based on the given \a row and \a col.
|
||||
*/
|
||||
Cell *Document::cellAt(int row, int col) const
|
||||
{
|
||||
return currentWorksheet()->cellAt(row, col);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Returns the value of the document's \a key property.
|
||||
*/
|
||||
|
||||
@@ -38,6 +38,7 @@ class Workbook;
|
||||
class Worksheet;
|
||||
class Package;
|
||||
class Format;
|
||||
class Cell;
|
||||
|
||||
class DocumentPrivate;
|
||||
class Q_XLSX_EXPORT Document : public QObject
|
||||
@@ -60,6 +61,9 @@ public:
|
||||
bool setRow(int row, double height, Format* format=0, bool hidden=false);
|
||||
bool setColumn(int colFirst, int colLast, double width, Format* format=0, bool hidden=false);
|
||||
|
||||
Cell *cellAt(const QString &cell) const;
|
||||
Cell *cellAt(int row, int col) const;
|
||||
|
||||
QString documentProperty(const QString &name) const;
|
||||
void setDocumentProperty(const QString &name, const QString &property);
|
||||
QStringList documentPropertyNames() const;
|
||||
|
||||
@@ -337,6 +337,26 @@ int Worksheet::write(const QString row_column, const QVariant &value, Format *fo
|
||||
return write(pos.x(), pos.y(), value, format);
|
||||
}
|
||||
|
||||
Cell *Worksheet::cellAt(const QString &row_column) const
|
||||
{
|
||||
QPoint pos = xl_cell_to_rowcol(row_column);
|
||||
if (pos == QPoint(-1, -1))
|
||||
return 0;
|
||||
|
||||
return cellAt(pos.x(), pos.y());
|
||||
}
|
||||
|
||||
Cell *Worksheet::cellAt(int row, int column) const
|
||||
{
|
||||
Q_D(const Worksheet);
|
||||
if (!d->cellTable.contains(row))
|
||||
return 0;
|
||||
if (!d->cellTable[row].contains(column))
|
||||
return 0;
|
||||
|
||||
return d->cellTable[row][column].data();
|
||||
}
|
||||
|
||||
int Worksheet::writeString(int row, int column, const QString &value, Format *format)
|
||||
{
|
||||
Q_D(Worksheet);
|
||||
|
||||
@@ -26,6 +26,7 @@
|
||||
#define XLSXWORKSHEET_H
|
||||
|
||||
#include "xlsxglobal.h"
|
||||
#include "xlsxcell.h"
|
||||
#include <QStringList>
|
||||
#include <QMap>
|
||||
#include <QVariant>
|
||||
@@ -59,6 +60,9 @@ public:
|
||||
int writeDateTime(int row, int column, const QDateTime& dt, Format *format=0);
|
||||
int writeUrl(int row, int column, const QUrl &url, Format *format=0, const QString &display=QString(), const QString &tip=QString());
|
||||
|
||||
Cell *cellAt(const QString &row_column) const;
|
||||
Cell *cellAt(int row, int column) const;
|
||||
|
||||
int insertImage(int row, int column, const QImage &image, const QPointF &offset=QPointF(), double xScale=1, double yScale=1);
|
||||
|
||||
int mergeCells(int row_begin, int column_begin, int row_end, int column_end);
|
||||
|
||||
Reference in New Issue
Block a user