xlsxworksheet.h 6.3 KB

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