xlsxworksheet.h 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. // xlsxworksheet.h
  2. #ifndef XLSXWORKSHEET_H
  3. #define XLSXWORKSHEET_H
  4. #include "xlsxabstractsheet.h"
  5. #include "xlsxcell.h"
  6. #include "xlsxcelllocation.h"
  7. #include "xlsxcellrange.h"
  8. #include "xlsxcellreference.h"
  9. #include <QDateTime>
  10. #include <QIODevice>
  11. #include <QImage>
  12. #include <QMap>
  13. #include <QObject>
  14. #include <QPointF>
  15. #include <QStringList>
  16. #include <QUrl>
  17. #include <QVariant>
  18. class WorksheetTest;
  19. QT_BEGIN_NAMESPACE_XLSX
  20. class DocumentPrivate;
  21. class Workbook;
  22. class Format;
  23. class Drawing;
  24. class DataValidation;
  25. class ConditionalFormatting;
  26. class CellRange;
  27. class RichString;
  28. class Relationships;
  29. class Chart;
  30. class WorksheetPrivate;
  31. class QXLSX_EXPORT Worksheet : public AbstractSheet
  32. {
  33. Q_DECLARE_PRIVATE(Worksheet)
  34. private:
  35. friend class DocumentPrivate;
  36. friend class Workbook;
  37. friend class ::WorksheetTest;
  38. Worksheet(const QString &sheetName, int sheetId, Workbook *book, CreateFlag flag);
  39. Worksheet *copy(const QString &distName, int distId) const override;
  40. public:
  41. ~Worksheet();
  42. public:
  43. bool write(const CellReference &row_column,
  44. const QVariant &value,
  45. const Format &format = Format());
  46. bool write(int row, int column, const QVariant &value, const Format &format = Format());
  47. QVariant read(const CellReference &row_column) const;
  48. QVariant read(int row, int column) const;
  49. bool writeString(const CellReference &row_column,
  50. const QString &value,
  51. const Format &format = Format());
  52. bool writeString(int row, int column, const QString &value, const Format &format = Format());
  53. bool writeString(const CellReference &row_column,
  54. const RichString &value,
  55. const Format &format = Format());
  56. bool writeString(int row, int column, const RichString &value, const Format &format = Format());
  57. bool writeInlineString(const CellReference &row_column,
  58. const QString &value,
  59. const Format &format = Format());
  60. bool writeInlineString(int row,
  61. int column,
  62. const QString &value,
  63. const Format &format = Format());
  64. bool writeNumeric(const CellReference &row_column,
  65. double value,
  66. const Format &format = Format());
  67. bool writeNumeric(int row, int column, double value, const Format &format = Format());
  68. bool writeFormula(const CellReference &row_column,
  69. const CellFormula &formula,
  70. const Format &format = Format(),
  71. double result = 0);
  72. bool writeFormula(int row,
  73. int column,
  74. const CellFormula &formula,
  75. const Format &format = Format(),
  76. double result = 0);
  77. bool writeBlank(const CellReference &row_column, const Format &format = Format());
  78. bool writeBlank(int row, int column, const Format &format = Format());
  79. bool writeBool(const CellReference &row_column, bool value, const Format &format = Format());
  80. bool writeBool(int row, int column, bool value, const Format &format = Format());
  81. bool writeDateTime(const CellReference &row_column,
  82. const QDateTime &dt,
  83. const Format &format = Format());
  84. bool writeDateTime(int row, int column, const QDateTime &dt, const Format &format = Format());
  85. // dev67
  86. bool writeDate(const CellReference &row_column,
  87. const QDate &dt,
  88. const Format &format = Format());
  89. bool writeDate(int row, int column, const QDate &dt, const Format &format = Format());
  90. bool
  91. writeTime(const CellReference &row_column, const QTime &t, const Format &format = Format());
  92. bool writeTime(int row, int column, const QTime &t, const Format &format = Format());
  93. bool writeHyperlink(const CellReference &row_column,
  94. const QUrl &url,
  95. const Format &format = Format(),
  96. const QString &display = QString(),
  97. const QString &tip = QString());
  98. bool writeHyperlink(int row,
  99. int column,
  100. const QUrl &url,
  101. const Format &format = Format(),
  102. const QString &display = QString(),
  103. const QString &tip = QString());
  104. bool addDataValidation(const DataValidation &validation);
  105. bool addConditionalFormatting(const ConditionalFormatting &cf);
  106. std::shared_ptr<Cell> cellAt(const CellReference &row_column) const;
  107. std::shared_ptr<Cell> cellAt(int row, int column) const;
  108. int insertImage(int row, int column, const QImage &image);
  109. bool getImage(int imageIndex, QImage &img);
  110. bool getImage(int row, int column, QImage &img);
  111. uint getImageCount();
  112. Chart *insertChart(int row, int column, const QSize &size);
  113. bool mergeCells(const CellRange &range, const Format &format = Format());
  114. bool unmergeCells(const CellRange &range);
  115. QList<CellRange> mergedCells() const;
  116. bool setColumnWidth(const CellRange &range, double width);
  117. bool setColumnFormat(const CellRange &range, const Format &format);
  118. bool setColumnHidden(const CellRange &range, bool hidden);
  119. bool setColumnWidth(int colFirst, int colLast, double width);
  120. bool setColumnFormat(int colFirst, int colLast, const Format &format);
  121. bool setColumnHidden(int colFirst, int colLast, bool hidden);
  122. double columnWidth(int column);
  123. Format columnFormat(int column);
  124. bool isColumnHidden(int column);
  125. bool setRowHeight(int rowFirst, int rowLast, double height);
  126. bool setRowFormat(int rowFirst, int rowLast, const Format &format);
  127. bool setRowHidden(int rowFirst, int rowLast, bool hidden);
  128. double rowHeight(int row);
  129. Format rowFormat(int row);
  130. bool isRowHidden(int row);
  131. bool groupRows(int rowFirst, int rowLast, bool collapsed = true);
  132. bool groupColumns(int colFirst, int colLast, bool collapsed = true);
  133. bool groupColumns(const CellRange &range, bool collapsed = true);
  134. CellRange dimension() const;
  135. bool isWindowProtected() const;
  136. void setWindowProtected(bool protect);
  137. bool isFormulasVisible() const;
  138. void setFormulasVisible(bool visible);
  139. bool isGridLinesVisible() const;
  140. void setGridLinesVisible(bool visible);
  141. bool isRowColumnHeadersVisible() const;
  142. void setRowColumnHeadersVisible(bool visible);
  143. bool isZerosVisible() const;
  144. void setZerosVisible(bool visible);
  145. bool isRightToLeft() const;
  146. void setRightToLeft(bool enable);
  147. bool isSelected() const;
  148. void setSelected(bool select);
  149. bool isRulerVisible() const;
  150. void setRulerVisible(bool visible);
  151. bool isOutlineSymbolsVisible() const;
  152. void setOutlineSymbolsVisible(bool visible);
  153. bool isWhiteSpaceVisible() const;
  154. void setWhiteSpaceVisible(bool visible);
  155. bool setStartPage(int spagen); // add by liufeijin20181028
  156. QVector<CellLocation> getFullCells(int *maxRow, int *maxCol) const;
  157. private:
  158. void saveToXmlFile(QIODevice *device) const override;
  159. bool loadFromXmlFile(QIODevice *device) override;
  160. };
  161. QT_END_NAMESPACE_XLSX
  162. #endif // XLSXWORKSHEET_H