xlsxworksheet.h 7.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. /****************************************************************************
  2. ** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
  3. ** All right reserved.
  4. **
  5. ** Permission is hereby granted, free of charge, to any person obtaining
  6. ** a copy of this software and associated documentation files (the
  7. ** "Software"), to deal in the Software without restriction, including
  8. ** without limitation the rights to use, copy, modify, merge, publish,
  9. ** distribute, sublicense, and/or sell copies of the Software, and to
  10. ** permit persons to whom the Software is furnished to do so, subject to
  11. ** the following conditions:
  12. **
  13. ** The above copyright notice and this permission notice shall be
  14. ** included in all copies or substantial portions of the Software.
  15. **
  16. ** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  17. ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  18. ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  19. ** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  20. ** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  21. ** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  22. ** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. **
  24. ****************************************************************************/
  25. #ifndef XLSXWORKSHEET_H
  26. #define XLSXWORKSHEET_H
  27. #include "xlsxabstractsheet.h"
  28. #include "xlsxcell.h"
  29. #include "xlsxcellrange.h"
  30. #include "xlsxcellreference.h"
  31. #include <QStringList>
  32. #include <QMap>
  33. #include <QVariant>
  34. #include <QPointF>
  35. #include <QSharedPointer>
  36. class QIODevice;
  37. class QDateTime;
  38. class QUrl;
  39. class QImage;
  40. class WorksheetTest;
  41. QT_BEGIN_NAMESPACE_XLSX
  42. class DocumentPrivate;
  43. class Workbook;
  44. class Format;
  45. class Drawing;
  46. class DataValidation;
  47. class ConditionalFormatting;
  48. class CellRange;
  49. class RichString;
  50. class Relationships;
  51. class Chart;
  52. class WorksheetPrivate;
  53. class Q_XLSX_EXPORT Worksheet : public AbstractSheet
  54. {
  55. Q_DECLARE_PRIVATE(Worksheet)
  56. public:
  57. bool write(const CellReference &row_column, const QVariant &value, const Format &format=Format());
  58. bool write(int row, int column, const QVariant &value, const Format &format=Format());
  59. QVariant read(const CellReference &row_column) const;
  60. QVariant read(int row, int column) const;
  61. bool writeString(const CellReference &row_column, const QString &value, const Format &format=Format());
  62. bool writeString(int row, int column, const QString &value, const Format &format=Format());
  63. bool writeString(const CellReference &row_column, const RichString &value, const Format &format=Format());
  64. bool writeString(int row, int column, const RichString &value, const Format &format=Format());
  65. bool writeInlineString(const CellReference &row_column, const QString &value, const Format &format=Format());
  66. bool writeInlineString(int row, int column, const QString &value, const Format &format=Format());
  67. bool writeNumeric(const CellReference &row_column, double value, const Format &format=Format());
  68. bool writeNumeric(int row, int column, double value, const Format &format=Format());
  69. bool writeFormula(const CellReference &row_column, const CellFormula &formula, const Format &format=Format(), double result=0);
  70. bool writeFormula(int row, int column, const CellFormula &formula, const Format &format=Format(), double result=0);
  71. bool writeBlank(const CellReference &row_column, const Format &format=Format());
  72. bool writeBlank(int row, int column, const Format &format=Format());
  73. bool writeBool(const CellReference &row_column, bool value, const Format &format=Format());
  74. bool writeBool(int row, int column, bool value, const Format &format=Format());
  75. bool writeDateTime(const CellReference &row_column, const QDateTime& dt, const Format &format=Format());
  76. bool writeDateTime(int row, int column, const QDateTime& dt, const Format &format=Format());
  77. bool writeTime(const CellReference &row_column, const QTime& t, const Format &format=Format());
  78. bool writeTime(int row, int column, const QTime& t, const Format &format=Format());
  79. bool writeHyperlink(const CellReference &row_column, const QUrl &url, const Format &format=Format(), const QString &display=QString(), const QString &tip=QString());
  80. bool writeHyperlink(int row, int column, const QUrl &url, const Format &format=Format(), const QString &display=QString(), const QString &tip=QString());
  81. bool addDataValidation(const DataValidation &validation);
  82. bool addConditionalFormatting(const ConditionalFormatting &cf);
  83. Cell *cellAt(const CellReference &row_column) const;
  84. Cell *cellAt(int row, int column) const;
  85. bool insertImage(int row, int column, const QImage &image);
  86. Chart *insertChart(int row, int column, const QSize &size);
  87. bool mergeCells(const CellRange &range, const Format &format=Format());
  88. bool unmergeCells(const CellRange &range);
  89. QList<CellRange> mergedCells() const;
  90. bool setColumnWidth(const CellRange& range, double width);
  91. bool setColumnFormat(const CellRange& range, const Format &format);
  92. bool setColumnHidden(const CellRange& range, bool hidden);
  93. bool setColumnWidth(int colFirst, int colLast, double width);
  94. bool setColumnFormat(int colFirst, int colLast, const Format &format);
  95. bool setColumnHidden(int colFirst, int colLast, bool hidden);
  96. double columnWidth(int column);
  97. Format columnFormat(int column);
  98. bool isColumnHidden(int column);
  99. bool setRowHeight(int rowFirst,int rowLast, double height);
  100. bool setRowFormat(int rowFirst,int rowLast, const Format &format);
  101. bool setRowHidden(int rowFirst,int rowLast, bool hidden);
  102. double rowHeight(int row);
  103. Format rowFormat(int row);
  104. bool isRowHidden(int row);
  105. bool groupRows(int rowFirst, int rowLast, bool collapsed = true);
  106. bool groupColumns(int colFirst, int colLast, bool collapsed = true);
  107. bool groupColumns(const CellRange &range, bool collapsed = true);
  108. CellRange dimension() const;
  109. bool isWindowProtected() const;
  110. void setWindowProtected(bool protect);
  111. bool isFormulasVisible() const;
  112. void setFormulasVisible(bool visible);
  113. bool isGridLinesVisible() const;
  114. void setGridLinesVisible(bool visible);
  115. bool isRowColumnHeadersVisible() const;
  116. void setRowColumnHeadersVisible(bool visible);
  117. bool isZerosVisible() const;
  118. void setZerosVisible(bool visible);
  119. bool isRightToLeft() const;
  120. void setRightToLeft(bool enable);
  121. bool isSelected() const;
  122. void setSelected(bool select);
  123. bool isRulerVisible() const;
  124. void setRulerVisible(bool visible);
  125. bool isOutlineSymbolsVisible() const;
  126. void setOutlineSymbolsVisible(bool visible);
  127. bool isWhiteSpaceVisible() const;
  128. void setWhiteSpaceVisible(bool visible);
  129. ~Worksheet();
  130. private:
  131. friend class DocumentPrivate;
  132. friend class Workbook;
  133. friend class ::WorksheetTest;
  134. Worksheet(const QString &sheetName, int sheetId, Workbook *book, CreateFlag flag);
  135. Worksheet *copy(const QString &distName, int distId) const;
  136. void saveToXmlFile(QIODevice *device) const;
  137. bool loadFromXmlFile(QIODevice *device);
  138. };
  139. QT_END_NAMESPACE_XLSX
  140. #endif // XLSXWORKSHEET_H