xlsxworkbook.h 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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 XLSXWORKBOOK_H
  26. #define XLSXWORKBOOK_H
  27. #include "xlsxglobal.h"
  28. #include "xlsxabstractooxmlfile.h"
  29. #include "xlsxabstractsheet.h"
  30. #include <QList>
  31. #include <QImage>
  32. #include <QSharedPointer>
  33. class QIODevice;
  34. QT_BEGIN_NAMESPACE_XLSX
  35. class SharedStrings;
  36. class Styles;
  37. class Drawing;
  38. class Document;
  39. class Theme;
  40. class Relationships;
  41. class DocumentPrivate;
  42. class MediaFile;
  43. class Chart;
  44. class Chartsheet;
  45. class Worksheet;
  46. class WorkbookPrivate;
  47. class Q_XLSX_EXPORT Workbook : public AbstractOOXmlFile
  48. {
  49. Q_DECLARE_PRIVATE(Workbook)
  50. public:
  51. ~Workbook();
  52. int sheetCount() const;
  53. AbstractSheet *sheet(int index) const;
  54. AbstractSheet *addSheet(const QString &name = QString(), AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
  55. AbstractSheet *insertSheet(int index, const QString &name = QString(), AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
  56. bool renameSheet(int index, const QString &name);
  57. bool deleteSheet(int index);
  58. bool copySheet(int index, const QString &newName=QString());
  59. bool moveSheet(int srcIndex, int distIndex);
  60. AbstractSheet *activeSheet() const;
  61. bool setActiveSheet(int index);
  62. // void addChart();
  63. bool defineName(const QString &name, const QString &formula, const QString &comment=QString(), const QString &scope=QString());
  64. bool isDate1904() const;
  65. void setDate1904(bool date1904);
  66. bool isStringsToNumbersEnabled() const;
  67. void setStringsToNumbersEnabled(bool enable=true);
  68. bool isStringsToHyperlinksEnabled() const;
  69. void setStringsToHyperlinksEnabled(bool enable=true);
  70. bool isHtmlToRichStringEnabled() const;
  71. void setHtmlToRichStringEnabled(bool enable=true);
  72. QString defaultDateFormat() const;
  73. void setDefaultDateFormat(const QString &format);
  74. //internal used member
  75. void addMediaFile(QSharedPointer<MediaFile> media, bool force=false);
  76. QList<QSharedPointer<MediaFile> > mediaFiles() const;
  77. void addChartFile(QSharedPointer<Chart> chartFile);
  78. QList<QSharedPointer<Chart> > chartFiles() const;
  79. private:
  80. friend class Worksheet;
  81. friend class Chartsheet;
  82. friend class WorksheetPrivate;
  83. friend class Document;
  84. friend class DocumentPrivate;
  85. Workbook(Workbook::CreateFlag flag);
  86. void saveToXmlFile(QIODevice *device) const;
  87. bool loadFromXmlFile(QIODevice *device);
  88. SharedStrings *sharedStrings() const;
  89. Styles *styles();
  90. Theme *theme();
  91. QList<QImage> images();
  92. QList<Drawing *> drawings();
  93. QList<QSharedPointer<AbstractSheet> > getSheetsByTypes(AbstractSheet::SheetType type) const;
  94. QStringList worksheetNames() const;
  95. AbstractSheet *addSheet(const QString &name, int sheetId, AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
  96. };
  97. QT_END_NAMESPACE_XLSX
  98. #endif // XLSXWORKBOOK_H