xlsxworksheet.h 7.2 KB

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