File indexing completed on 2024-06-23 03:45:57
0001 // xlsxworksheet.h 0002 0003 #ifndef XLSXWORKSHEET_H 0004 #define XLSXWORKSHEET_H 0005 0006 #include <QtGlobal> 0007 #include <QObject> 0008 #include <QStringList> 0009 #include <QMap> 0010 #include <QVariant> 0011 #include <QPointF> 0012 #include <QIODevice> 0013 #include <QDateTime> 0014 #include <QUrl> 0015 #include <QImage> 0016 0017 #include "xlsxabstractsheet.h" 0018 #include "xlsxcell.h" 0019 #include "xlsxcellrange.h" 0020 #include "xlsxcellreference.h" 0021 #include "xlsxcelllocation.h" 0022 0023 class WorksheetTest; 0024 0025 QT_BEGIN_NAMESPACE_XLSX 0026 0027 class DocumentPrivate; 0028 class Workbook; 0029 class Format; 0030 class Drawing; 0031 class DataValidation; 0032 class ConditionalFormatting; 0033 class CellRange; 0034 class RichString; 0035 class Relationships; 0036 class Chart; 0037 0038 class WorksheetPrivate; 0039 class QXLSX_EXPORT Worksheet : public AbstractSheet 0040 { 0041 Q_DECLARE_PRIVATE(Worksheet) 0042 0043 private: 0044 friend class DocumentPrivate; 0045 friend class Workbook; 0046 friend class ::WorksheetTest; 0047 Worksheet(const QString &sheetName, int sheetId, Workbook *book, CreateFlag flag); 0048 Worksheet *copy(const QString &distName, int distId) const override; 0049 0050 public: 0051 ~Worksheet(); 0052 0053 public: 0054 bool write(const CellReference &row_column, const QVariant &value, const Format &format=Format()); 0055 bool write(int row, int column, const QVariant &value, const Format &format=Format()); 0056 0057 QVariant read(const CellReference &row_column) const; 0058 QVariant read(int row, int column) const; 0059 0060 bool writeString(const CellReference &row_column, const QString &value, const Format &format=Format()); 0061 bool writeString(int row, int column, const QString &value, const Format &format=Format()); 0062 bool writeString(const CellReference &row_column, const RichString &value, const Format &format=Format()); 0063 bool writeString(int row, int column, const RichString &value, const Format &format=Format()); 0064 0065 bool writeInlineString(const CellReference &row_column, const QString &value, const Format &format=Format()); 0066 bool writeInlineString(int row, int column, const QString &value, const Format &format=Format()); 0067 0068 bool writeNumeric(const CellReference &row_column, double value, const Format &format=Format()); 0069 bool writeNumeric(int row, int column, double value, const Format &format=Format()); 0070 0071 bool writeFormula(const CellReference &row_column, const CellFormula &formula, const Format &format=Format(), double result=0); 0072 bool writeFormula(int row, int column, const CellFormula &formula, const Format &format=Format(), double result=0); 0073 0074 bool writeBlank(const CellReference &row_column, const Format &format=Format()); 0075 bool writeBlank(int row, int column, const Format &format=Format()); 0076 0077 bool writeBool(const CellReference &row_column, bool value, const Format &format=Format()); 0078 bool writeBool(int row, int column, bool value, const Format &format=Format()); 0079 0080 bool writeDateTime(const CellReference &row_column, const QDateTime& dt, const Format &format=Format()); 0081 bool writeDateTime(int row, int column, const QDateTime& dt, const Format &format=Format()); 0082 0083 // dev67 0084 bool writeDate(const CellReference &row_column, const QDate& dt, const Format &format=Format()); 0085 bool writeDate(int row, int column, const QDate& dt, const Format &format=Format()); 0086 0087 bool writeTime(const CellReference &row_column, const QTime& t, const Format &format=Format()); 0088 bool writeTime(int row, int column, const QTime& t, const Format &format=Format()); 0089 0090 bool writeHyperlink(const CellReference &row_column, const QUrl &url, const Format &format=Format(), const QString &display=QString(), const QString &tip=QString()); 0091 bool writeHyperlink(int row, int column, const QUrl &url, const Format &format=Format(), const QString &display=QString(), const QString &tip=QString()); 0092 0093 bool addDataValidation(const DataValidation &validation); 0094 bool addConditionalFormatting(const ConditionalFormatting &cf); 0095 0096 Cell *cellAt(const CellReference &row_column) const; 0097 Cell *cellAt(int row, int column) const; 0098 0099 int insertImage(int row, int column, const QImage &image); 0100 bool getImage(int imageIndex, QImage& img); 0101 bool getImage(int row, int column, QImage& img); 0102 uint getImageCount(); 0103 0104 Chart *insertChart(int row, int column, const QSize &size); 0105 0106 bool mergeCells(const CellRange &range, const Format &format=Format()); 0107 bool unmergeCells(const CellRange &range); 0108 QList<CellRange> mergedCells() const; 0109 0110 bool setColumnWidth(const CellRange& range, double width); 0111 bool setColumnFormat(const CellRange& range, const Format &format); 0112 bool setColumnHidden(const CellRange& range, bool hidden); 0113 bool setColumnWidth(int colFirst, int colLast, double width); 0114 bool setColumnFormat(int colFirst, int colLast, const Format &format); 0115 bool setColumnHidden(int colFirst, int colLast, bool hidden); 0116 0117 double columnWidth(int column); 0118 Format columnFormat(int column); 0119 bool isColumnHidden(int column); 0120 0121 bool setRowHeight(int rowFirst,int rowLast, double height); 0122 bool setRowFormat(int rowFirst,int rowLast, const Format &format); 0123 bool setRowHidden(int rowFirst,int rowLast, bool hidden); 0124 0125 double rowHeight(int row); 0126 Format rowFormat(int row); 0127 bool isRowHidden(int row); 0128 0129 bool groupRows(int rowFirst, int rowLast, bool collapsed = true); 0130 bool groupColumns(int colFirst, int colLast, bool collapsed = true); 0131 bool groupColumns(const CellRange &range, bool collapsed = true); 0132 CellRange dimension() const; 0133 0134 bool isWindowProtected() const; 0135 void setWindowProtected(bool protect); 0136 bool isFormulasVisible() const; 0137 void setFormulasVisible(bool visible); 0138 bool isGridLinesVisible() const; 0139 void setGridLinesVisible(bool visible); 0140 bool isRowColumnHeadersVisible() const; 0141 void setRowColumnHeadersVisible(bool visible); 0142 bool isZerosVisible() const; 0143 void setZerosVisible(bool visible); 0144 bool isRightToLeft() const; 0145 void setRightToLeft(bool enable); 0146 bool isSelected() const; 0147 void setSelected(bool select); 0148 bool isRulerVisible() const; 0149 void setRulerVisible(bool visible); 0150 bool isOutlineSymbolsVisible() const; 0151 void setOutlineSymbolsVisible(bool visible); 0152 bool isWhiteSpaceVisible() const; 0153 void setWhiteSpaceVisible(bool visible); 0154 bool setStartPage(int spagen); //add by liufeijin20181028 0155 0156 QVector<CellLocation> getFullCells(int* maxRow, int* maxCol); 0157 0158 private: 0159 void saveToXmlFile(QIODevice *device) const override; 0160 bool loadFromXmlFile(QIODevice *device) override; 0161 }; 0162 0163 QT_END_NAMESPACE_XLSX 0164 #endif // XLSXWORKSHEET_H