andre@1: /**************************************************************************** andre@1: ** Copyright (c) 2013-2014 Debao Zhang 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: andre@1: #ifndef QXLSX_XLSXDOCUMENT_H andre@1: #define QXLSX_XLSXDOCUMENT_H andre@1: andre@1: #include "xlsxglobal.h" andre@1: #include "xlsxformat.h" andre@1: #include "xlsxworksheet.h" andre@1: #include andre@1: #include andre@1: class QIODevice; andre@1: class QImage; andre@1: andre@1: QT_BEGIN_NAMESPACE_XLSX andre@1: andre@1: class Workbook; andre@1: class Cell; andre@1: class CellRange; andre@1: class DataValidation; andre@1: class ConditionalFormatting; andre@1: class Chart; andre@1: class CellReference; andre@1: andre@1: class DocumentPrivate; andre@1: class Q_XLSX_EXPORT Document : public QObject andre@1: { andre@1: Q_OBJECT andre@1: Q_DECLARE_PRIVATE(Document) andre@1: andre@1: public: andre@1: explicit Document(QObject *parent = 0); andre@1: Document(const QString &xlsxName, QObject *parent=0); andre@1: Document(QIODevice *device, QObject *parent=0); andre@1: ~Document(); andre@1: andre@1: bool write(const CellReference &cell, const QVariant &value, const Format &format=Format()); andre@1: bool write(int row, int col, const QVariant &value, const Format &format=Format()); andre@1: QVariant read(const CellReference &cell) const; andre@1: QVariant read(int row, int col) const; andre@1: bool insertImage(int row, int col, const QImage &image); andre@1: Chart *insertChart(int row, int col, const QSize &size); andre@1: bool mergeCells(const CellRange &range, const Format &format=Format()); andre@1: bool unmergeCells(const CellRange &range); 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 column, double width); andre@1: bool setColumnFormat(int column, const Format &format); andre@1: bool setColumnHidden(int column, 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 row, double height); andre@1: bool setRowFormat(int row, const Format &format); andre@1: bool setRowHidden(int row, bool hidden); 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 addDataValidation(const DataValidation &validation); andre@1: bool addConditionalFormatting(const ConditionalFormatting &cf); andre@1: andre@1: Cell *cellAt(const CellReference &cell) const; andre@1: Cell *cellAt(int row, int col) const; andre@1: andre@1: bool defineName(const QString &name, const QString &formula, const QString &comment=QString(), const QString &scope=QString()); andre@1: andre@1: CellRange dimension() const; andre@1: andre@1: QString documentProperty(const QString &name) const; andre@1: void setDocumentProperty(const QString &name, const QString &property); andre@1: QStringList documentPropertyNames() const; andre@1: andre@1: QStringList sheetNames() const; andre@1: bool addSheet(const QString &name = QString(), AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet); andre@1: bool insertSheet(int index, const QString &name = QString(), AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet); andre@1: bool selectSheet(const QString &name); andre@1: bool renameSheet(const QString &oldName, const QString &newName); andre@1: bool copySheet(const QString &srcName, const QString &distName = QString()); andre@1: bool moveSheet(const QString &srcName, int distIndex); andre@1: bool deleteSheet(const QString &name); andre@1: andre@1: Workbook *workbook() const; andre@1: AbstractSheet *sheet(const QString &sheetName) const; andre@1: AbstractSheet *currentSheet() const; andre@1: Worksheet *currentWorksheet() const; andre@1: andre@1: bool save() const; andre@1: bool saveAs(const QString &xlsXname) const; andre@1: bool saveAs(QIODevice *device) const; andre@1: andre@1: private: andre@1: Q_DISABLE_COPY(Document) andre@1: DocumentPrivate * const d_ptr; andre@1: }; andre@1: andre@1: QT_END_NAMESPACE_XLSX andre@1: andre@1: #endif // QXLSX_XLSXDOCUMENT_H