andre@1: /****************************************************************************
andre@1: ** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
andre@1: ** All right reserved.
andre@1: **
andre@1: ** Permission is hereby granted, free of charge, to any person obtaining
andre@1: ** a copy of this software and associated documentation files (the
andre@1: ** "Software"), to deal in the Software without restriction, including
andre@1: ** without limitation the rights to use, copy, modify, merge, publish,
andre@1: ** distribute, sublicense, and/or sell copies of the Software, and to
andre@1: ** permit persons to whom the Software is furnished to do so, subject to
andre@1: ** the following conditions:
andre@1: **
andre@1: ** The above copyright notice and this permission notice shall be
andre@1: ** included in all copies or substantial portions of the Software.
andre@1: **
andre@1: ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
andre@1: ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
andre@1: ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
andre@1: ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
andre@1: ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
andre@1: ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
andre@1: ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
andre@1: **
andre@1: ****************************************************************************/
andre@1: #ifndef XLSXWORKSHEET_H
andre@1: #define XLSXWORKSHEET_H
andre@1: 
andre@1: #include "xlsxabstractsheet.h"
andre@1: #include "xlsxcell.h"
andre@1: #include "xlsxcellrange.h"
andre@1: #include "xlsxcellreference.h"
andre@1: #include <QStringList>
andre@1: #include <QMap>
andre@1: #include <QVariant>
andre@1: #include <QPointF>
andre@1: #include <QSharedPointer>
andre@1: class QIODevice;
andre@1: class QDateTime;
andre@1: class QUrl;
andre@1: class QImage;
andre@1: class WorksheetTest;
andre@1: 
andre@1: QT_BEGIN_NAMESPACE_XLSX
andre@1: class DocumentPrivate;
andre@1: class Workbook;
andre@1: class Format;
andre@1: class Drawing;
andre@1: class DataValidation;
andre@1: class ConditionalFormatting;
andre@1: class CellRange;
andre@1: class RichString;
andre@1: class Relationships;
andre@1: class Chart;
andre@1: 
andre@1: class WorksheetPrivate;
andre@1: class Q_XLSX_EXPORT Worksheet : public AbstractSheet
andre@1: {
andre@1:     Q_DECLARE_PRIVATE(Worksheet)
andre@1: public:
andre@1:     bool write(const CellReference &row_column, const QVariant &value, const Format &format=Format());
andre@1:     bool write(int row, int column, const QVariant &value, const Format &format=Format());
andre@1:     QVariant read(const CellReference &row_column) const;
andre@1:     QVariant read(int row, int column) const;
andre@1:     bool writeString(const CellReference &row_column, const QString &value, const Format &format=Format());
andre@1:     bool writeString(int row, int column, const QString &value, const Format &format=Format());
andre@1:     bool writeString(const CellReference &row_column, const RichString &value, const Format &format=Format());
andre@1:     bool writeString(int row, int column, const RichString &value, const Format &format=Format());
andre@1:     bool writeInlineString(const CellReference &row_column, const QString &value, const Format &format=Format());
andre@1:     bool writeInlineString(int row, int column, const QString &value, const Format &format=Format());
andre@1:     bool writeNumeric(const CellReference &row_column, double value, const Format &format=Format());
andre@1:     bool writeNumeric(int row, int column, double value, const Format &format=Format());
andre@1:     bool writeFormula(const CellReference &row_column, const CellFormula &formula, const Format &format=Format(), double result=0);
andre@1:     bool writeFormula(int row, int column, const CellFormula &formula, const Format &format=Format(), double result=0);
andre@1:     bool writeBlank(const CellReference &row_column, const Format &format=Format());
andre@1:     bool writeBlank(int row, int column, const Format &format=Format());
andre@1:     bool writeBool(const CellReference &row_column, bool value, const Format &format=Format());
andre@1:     bool writeBool(int row, int column, bool value, const Format &format=Format());
andre@1:     bool writeDateTime(const CellReference &row_column, const QDateTime& dt, const Format &format=Format());
andre@1:     bool writeDateTime(int row, int column, const QDateTime& dt, const Format &format=Format());
andre@1:     bool writeTime(const CellReference &row_column, const QTime& t, const Format &format=Format());
andre@1:     bool writeTime(int row, int column, const QTime& t, const Format &format=Format());
andre@1: 
andre@1:     bool writeHyperlink(const CellReference &row_column, const QUrl &url, const Format &format=Format(), const QString &display=QString(), const QString &tip=QString());
andre@1:     bool writeHyperlink(int row, int column, const QUrl &url, const Format &format=Format(), const QString &display=QString(), const QString &tip=QString());
andre@1: 
andre@1:     bool addDataValidation(const DataValidation &validation);
andre@1:     bool addConditionalFormatting(const ConditionalFormatting &cf);
andre@1: 
andre@1:     Cell *cellAt(const CellReference &row_column) const;
andre@1:     Cell *cellAt(int row, int column) const;
andre@1: 
andre@1:     bool insertImage(int row, int column, const QImage &image);
andre@1:     Chart *insertChart(int row, int column, const QSize &size);
andre@1: 
andre@1:     bool mergeCells(const CellRange &range, const Format &format=Format());
andre@1:     bool unmergeCells(const CellRange &range);
andre@1:     QList<CellRange> mergedCells() const;
andre@1: 
andre@1:     bool setColumnWidth(const CellRange& range, double width);
andre@1:     bool setColumnFormat(const CellRange& range, const Format &format);
andre@1:     bool setColumnHidden(const CellRange& range, bool hidden);
andre@1:     bool setColumnWidth(int colFirst, int colLast, double width);
andre@1:     bool setColumnFormat(int colFirst, int colLast, const Format &format);
andre@1:     bool setColumnHidden(int colFirst, int colLast, bool hidden);
andre@1:     double columnWidth(int column);
andre@1:     Format columnFormat(int column);
andre@1:     bool isColumnHidden(int column);
andre@1: 
andre@1:     bool setRowHeight(int rowFirst,int rowLast, double height);
andre@1:     bool setRowFormat(int rowFirst,int rowLast, const Format &format);
andre@1:     bool setRowHidden(int rowFirst,int rowLast, bool hidden);
andre@1: 
andre@1:     double rowHeight(int row);
andre@1:     Format rowFormat(int row);
andre@1:     bool isRowHidden(int row);
andre@1: 
andre@1:     bool groupRows(int rowFirst, int rowLast, bool collapsed = true);
andre@1:     bool groupColumns(int colFirst, int colLast, bool collapsed = true);
andre@1:     bool groupColumns(const CellRange &range, bool collapsed = true);
andre@1:     CellRange dimension() const;
andre@1: 
andre@1:     bool isWindowProtected() const;
andre@1:     void setWindowProtected(bool protect);
andre@1:     bool isFormulasVisible() const;
andre@1:     void setFormulasVisible(bool visible);
andre@1:     bool isGridLinesVisible() const;
andre@1:     void setGridLinesVisible(bool visible);
andre@1:     bool isRowColumnHeadersVisible() const;
andre@1:     void setRowColumnHeadersVisible(bool visible);
andre@1:     bool isZerosVisible() const;
andre@1:     void setZerosVisible(bool visible);
andre@1:     bool isRightToLeft() const;
andre@1:     void setRightToLeft(bool enable);
andre@1:     bool isSelected() const;
andre@1:     void setSelected(bool select);
andre@1:     bool isRulerVisible() const;
andre@1:     void setRulerVisible(bool visible);
andre@1:     bool isOutlineSymbolsVisible() const;
andre@1:     void setOutlineSymbolsVisible(bool visible);
andre@1:     bool isWhiteSpaceVisible() const;
andre@1:     void setWhiteSpaceVisible(bool visible);
andre@1: 
andre@1:     ~Worksheet();
andre@1: 
andre@1: 
andre@1: private:
andre@1:     friend class DocumentPrivate;
andre@1:     friend class Workbook;
andre@1:     friend class ::WorksheetTest;
andre@1:     Worksheet(const QString &sheetName, int sheetId, Workbook *book, CreateFlag flag);
andre@1:     Worksheet *copy(const QString &distName, int distId) const;
andre@1: 
andre@1:     void saveToXmlFile(QIODevice *device) const;
andre@1:     bool loadFromXmlFile(QIODevice *device);
andre@1: };
andre@1: 
andre@1: QT_END_NAMESPACE_XLSX
andre@1: #endif // XLSXWORKSHEET_H