Selaa lähdekoodia

V0.4.10
1、添加了xlsx的demo,但是还未编译通过

Apple 4 kuukautta sitten
vanhempi
commit
92bbfb974b

+ 2 - 1
CMakeLists.txt

@@ -147,5 +147,6 @@ file(GLOB GLOBAL_SRC
 # add_subdirectory(${CMAKE_SOURCE_DIR}/demo/OneThread)
 # add_subdirectory(${CMAKE_SOURCE_DIR}/demo/timer)
 # add_subdirectory(${CMAKE_SOURCE_DIR}/demo/time)
-add_subdirectory(${CMAKE_SOURCE_DIR}/demo/VideoPlayer)
+# add_subdirectory(${CMAKE_SOURCE_DIR}/demo/VideoPlayer)
+add_subdirectory(${CMAKE_SOURCE_DIR}/demo/xlsx)
 

+ 78 - 0
demo/xlsx/CMakeLists.txt

@@ -0,0 +1,78 @@
+cmake_minimum_required(VERSION 3.5)
+
+set(this_exe xlsx)
+
+
+#包含源文件
+file(GLOB LOCAL_SRC
+    ${CMAKE_CURRENT_SOURCE_DIR}/*.qrc
+    ${CMAKE_CURRENT_SOURCE_DIR}/*.rc
+    ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
+    ${CMAKE_CURRENT_SOURCE_DIR}/*.ui
+
+    ${CMAKE_SOURCE_DIR}/External/common/Logs/*.cpp    
+)
+
+
+# 生成可执行程序
+add_executable(${this_exe}
+    # WIN32
+    ${GLOBAL_SRC}
+    ${LOCAL_SRC} 
+)
+
+# set_target_properties(${this_exe} PROPERTIES
+    
+# )
+
+
+#添加头文件
+target_include_directories(${this_exe} PRIVATE
+
+    ${CMAKE_CURRENT_SOURCE_DIR}
+    ${CMAKE_CURRENT_SOURCE_DIR}/QXlsx/QXlsx
+
+    ${CMAKE_SOURCE_DIR}/External/common
+    ${CMAKE_SOURCE_DIR}/External/common/FmtLog
+
+)
+
+target_link_libraries(${this_exe} PRIVATE
+    Qt5::Widgets
+    Qt5::Core
+    Qt5::Network
+    # Qt5::Multimedia
+    # Qt5::Xml
+    # Qt5::Sql
+)
+
+target_link_libraries(${this_exe} PRIVATE 
+    fmt::fmt
+    spdlog::spdlog
+    ${CMAKE_CURRENT_SOURCE_DIR}/QXlsx/QXlsx/release/libQXlsx.a
+)
+
+if(CMAKE_CXX_COMPILER_VERSION LESS 9.0)
+    target_link_libraries(${this_exe} PRIVATE
+        stdc++fs
+    )
+endif()
+
+# target_link_libraries(${this_exe} PRIVATE
+#     ${CURL_LIBRARY}
+    
+# )
+# message(STATUS "CURL_LIBRARY: ${CURL_LIBRARY}")
+
+
+# if(CMAKE_CXX_COMPILER_ID MATCHES MSVC)
+#     target_link_libraries(${this_exe} PRIVATE
+#         # debug spdlogd.lib
+#         # optimized spdlog.lib
+#     )
+# elseif(CMAKE_CXX_COMPILER_ID MATCHES GNU)
+#     target_link_libraries(${this_exe} PRIVATE
+#         # debug 
+#         # optimized ${SM_DLL}
+#     )
+# endif()

+ 43 - 0
demo/xlsx/QXlsx/QXlsx/xlsxabstractooxmlfile.h

@@ -0,0 +1,43 @@
+// xlsxabstractooxmlfile.h
+
+#ifndef QXLSX_XLSXABSTRACTOOXMLFILE_H
+#define QXLSX_XLSXABSTRACTOOXMLFILE_H
+
+#include "xlsxglobal.h"
+
+QT_BEGIN_NAMESPACE_XLSX
+
+class Relationships;
+class AbstractOOXmlFilePrivate;
+
+class QXLSX_EXPORT AbstractOOXmlFile
+{
+    Q_DECLARE_PRIVATE(AbstractOOXmlFile)
+
+public:
+    enum CreateFlag { F_NewFromScratch, F_LoadFromExists };
+
+public:
+    virtual ~AbstractOOXmlFile();
+
+    virtual void saveToXmlFile(QIODevice *device) const = 0;
+    virtual bool loadFromXmlFile(QIODevice *device)     = 0;
+
+    virtual QByteArray saveToXmlData() const;
+    virtual bool loadFromXmlData(const QByteArray &data);
+
+    Relationships *relationships() const;
+
+    void setFilePath(const QString path);
+    QString filePath() const;
+
+protected:
+    AbstractOOXmlFile(CreateFlag flag);
+    AbstractOOXmlFile(AbstractOOXmlFilePrivate *d);
+
+    AbstractOOXmlFilePrivate *d_ptr;
+};
+
+QT_END_NAMESPACE_XLSX
+
+#endif // QXLSX_XLSXABSTRACTOOXMLFILE_H

+ 49 - 0
demo/xlsx/QXlsx/QXlsx/xlsxabstractsheet.h

@@ -0,0 +1,49 @@
+// xlsxabstractsheet.h
+
+#ifndef XLSXABSTRACTSHEET_H
+#define XLSXABSTRACTSHEET_H
+
+#include "xlsxabstractooxmlfile.h"
+#include "xlsxglobal.h"
+
+QT_BEGIN_NAMESPACE_XLSX
+
+class Workbook;
+class Drawing;
+class AbstractSheetPrivate;
+
+class QXLSX_EXPORT AbstractSheet : public AbstractOOXmlFile
+{
+    Q_DECLARE_PRIVATE(AbstractSheet)
+
+public:
+    Workbook *workbook() const;
+
+public:
+    // NOTE: If all Qt  compiler supports C++1x, recommend to use a 'class enum'.
+    enum SheetType { ST_WorkSheet, ST_ChartSheet, ST_DialogSheet, ST_MacroSheet };
+    enum SheetState { SS_Visible, SS_Hidden, SS_VeryHidden };
+
+public:
+    QString sheetName() const;
+    SheetType sheetType() const;
+    SheetState sheetState() const;
+    void setSheetState(SheetState ss);
+    bool isHidden() const;
+    bool isVisible() const;
+    void setHidden(bool hidden);
+    void setVisible(bool visible);
+
+protected:
+    friend class Workbook;
+    AbstractSheet(const QString &sheetName, int sheetId, Workbook *book, AbstractSheetPrivate *d);
+    virtual AbstractSheet *copy(const QString &distName, int distId) const = 0;
+    void setSheetName(const QString &sheetName);
+    void setSheetType(SheetType type);
+    int sheetId() const;
+
+    Drawing *drawing() const;
+};
+
+QT_END_NAMESPACE_XLSX
+#endif // XLSXABSTRACTSHEET_H

+ 81 - 0
demo/xlsx/QXlsx/QXlsx/xlsxcell.h

@@ -0,0 +1,81 @@
+// xlsxcell.h
+
+#ifndef QXLSX_XLSXCELL_H
+#define QXLSX_XLSXCELL_H
+
+#include "xlsxformat.h"
+#include "xlsxglobal.h"
+
+#include <cstdio>
+
+#include <QDate>
+#include <QDateTime>
+#include <QObject>
+#include <QString>
+#include <QTime>
+#include <QVariant>
+#include <QtGlobal>
+
+QT_BEGIN_NAMESPACE_XLSX
+
+class Worksheet;
+class Format;
+class CellFormula;
+class CellPrivate;
+class WorksheetPrivate;
+
+class QXLSX_EXPORT Cell
+{
+    Q_DECLARE_PRIVATE(Cell)
+
+private:
+    friend class Worksheet;
+    friend class WorksheetPrivate;
+
+public:
+    enum CellType // See ECMA 376, 18.18.11. ST_CellType (Cell Type) for more information.
+    {
+        BooleanType,
+        DateType,
+        ErrorType,
+        InlineStringType,
+        NumberType,
+        SharedStringType,
+        StringType,
+        CustomType, // custom or un-defined cell type
+    };
+
+public:
+    Cell(const QVariant &data = QVariant(),
+         CellType type        = NumberType,
+         const Format &format = Format(),
+         Worksheet *parent    = nullptr,
+         qint32 styleIndex    = (-1));
+    Cell(const Cell *const cell);
+    ~Cell();
+
+public:
+    CellPrivate *const d_ptr; // See D-pointer and Q-pointer of Qt, for more information.
+
+public:
+    CellType cellType() const;
+    QVariant value() const;
+    QVariant readValue() const;
+    Format format() const;
+
+    bool hasFormula() const;
+    CellFormula formula() const;
+
+    bool isDateTime() const;
+    QVariant dateTime() const; // QDateTime, QDate, QTime
+
+    bool isRichString() const;
+
+    qint32 styleNumber() const;
+
+    static bool isDateType(CellType cellType, const Format &format);
+};
+
+QT_END_NAMESPACE_XLSX
+
+#endif // QXLSX_XLSXCELL_H

+ 56 - 0
demo/xlsx/QXlsx/QXlsx/xlsxcellformula.h

@@ -0,0 +1,56 @@
+// xlsxcellformula.h
+
+#ifndef QXLSX_XLSXCELLFORMULA_H
+#define QXLSX_XLSXCELLFORMULA_H
+
+#include "xlsxglobal.h"
+
+#include <QExplicitlySharedDataPointer>
+
+class QXmlStreamWriter;
+class QXmlStreamReader;
+
+QT_BEGIN_NAMESPACE_XLSX
+
+class CellFormulaPrivate;
+class CellRange;
+class Worksheet;
+class WorksheetPrivate;
+
+class QXLSX_EXPORT CellFormula
+{
+public:
+    enum FormulaType { NormalType, ArrayType, DataTableType, SharedType };
+
+public:
+    CellFormula();
+    CellFormula(const char *formula, FormulaType type = NormalType);
+    CellFormula(const QString &formula, FormulaType type = NormalType);
+    CellFormula(const QString &formula, const CellRange &ref, FormulaType type);
+    CellFormula(const CellFormula &other);
+    ~CellFormula();
+
+public:
+    CellFormula &operator=(const CellFormula &other);
+    bool isValid() const;
+
+    FormulaType formulaType() const;
+    QString formulaText() const;
+    CellRange reference() const;
+    int sharedIndex() const;
+
+    bool operator==(const CellFormula &formula) const;
+    bool operator!=(const CellFormula &formula) const;
+
+    bool saveToXml(QXmlStreamWriter &writer) const;
+    bool loadFromXml(QXmlStreamReader &reader);
+
+private:
+    friend class Worksheet;
+    friend class WorksheetPrivate;
+    QExplicitlySharedDataPointer<CellFormulaPrivate> d;
+};
+
+QT_END_NAMESPACE_XLSX
+
+#endif // QXLSX_XLSXCELLFORMULA_H

+ 33 - 0
demo/xlsx/QXlsx/QXlsx/xlsxcelllocation.h

@@ -0,0 +1,33 @@
+// xlsxcelllocation.h
+
+#ifndef CELL_LOCATION_H
+#define CELL_LOCATION_H
+
+#include "xlsxglobal.h"
+
+#include <memory>
+
+#include <QList>
+#include <QMetaType>
+#include <QObject>
+#include <QString>
+#include <QVector>
+#include <QtGlobal>
+
+QT_BEGIN_NAMESPACE_XLSX
+
+class Cell;
+
+class QXLSX_EXPORT CellLocation
+{
+public:
+    CellLocation();
+
+    int col;
+    int row;
+
+    std::shared_ptr<Cell> cell;
+};
+
+QT_END_NAMESPACE_XLSX
+#endif

+ 74 - 0
demo/xlsx/QXlsx/QXlsx/xlsxcellrange.h

@@ -0,0 +1,74 @@
+// xlsxcellrange.h
+
+#ifndef QXLSX_XLSXCELLRANGE_H
+#define QXLSX_XLSXCELLRANGE_H
+
+#include "xlsxcellreference.h"
+#include "xlsxglobal.h"
+
+#include <QObject>
+#include <QtGlobal>
+
+QT_BEGIN_NAMESPACE_XLSX
+
+// dev57
+class QXLSX_EXPORT CellRange
+{
+public:
+    CellRange();
+    CellRange(int firstRow, int firstColumn, int lastRow, int lastColumn);
+    CellRange(const CellReference &topLeft, const CellReference &bottomRight);
+    CellRange(const QString &range);
+    CellRange(const char *range);
+    CellRange(const CellRange &other);
+    ~CellRange();
+
+    QString toString(bool row_abs = false, bool col_abs = false) const;
+    bool isValid() const;
+    inline void setFirstRow(int row) { top = row; }
+    inline void setLastRow(int row) { bottom = row; }
+    inline void setFirstColumn(int col) { left = col; }
+    inline void setLastColumn(int col) { right = col; }
+    inline int firstRow() const { return top; }
+    inline int lastRow() const { return bottom; }
+    inline int firstColumn() const { return left; }
+    inline int lastColumn() const { return right; }
+    inline int rowCount() const { return bottom - top + 1; }
+    inline int columnCount() const { return right - left + 1; }
+    inline CellReference topLeft() const { return CellReference(top, left); }
+    inline CellReference topRight() const { return CellReference(top, right); }
+    inline CellReference bottomLeft() const { return CellReference(bottom, left); }
+    inline CellReference bottomRight() const { return CellReference(bottom, right); }
+
+    inline void operator=(const CellRange &other)
+    {
+        top    = other.top;
+        bottom = other.bottom;
+        left   = other.left;
+        right  = other.right;
+    }
+    inline bool operator==(const CellRange &other) const
+    {
+        return top == other.top && bottom == other.bottom && left == other.left &&
+               right == other.right;
+    }
+    inline bool operator!=(const CellRange &other) const
+    {
+        return top != other.top || bottom != other.bottom || left != other.left ||
+               right != other.right;
+    }
+
+private:
+    void init(const QString &range);
+
+    int top;
+    int left;
+    int bottom;
+    int right;
+};
+
+QT_END_NAMESPACE_XLSX
+
+Q_DECLARE_TYPEINFO(QXlsx::CellRange, Q_MOVABLE_TYPE);
+
+#endif // QXLSX_XLSXCELLRANGE_H

+ 48 - 0
demo/xlsx/QXlsx/QXlsx/xlsxcellreference.h

@@ -0,0 +1,48 @@
+// xlsxcellreference.h
+
+#ifndef QXLSX_XLSXCELLREFERENCE_H
+#define QXLSX_XLSXCELLREFERENCE_H
+
+#include "xlsxglobal.h"
+
+#include <QtGlobal>
+
+QT_BEGIN_NAMESPACE_XLSX
+
+class QXLSX_EXPORT CellReference
+{
+public:
+    CellReference();
+    CellReference(int row, int column);
+    CellReference(const QString &cell);
+    CellReference(const char *cell);
+    CellReference(const CellReference &other);
+    ~CellReference();
+
+    QString toString(bool row_abs = false, bool col_abs = false) const;
+    static CellReference fromString(const QString &cell);
+    bool isValid() const;
+    inline void setRow(int row) { _row = row; }
+    inline void setColumn(int col) { _column = col; }
+    inline int row() const { return _row; }
+    inline int column() const { return _column; }
+
+    inline bool operator==(const CellReference &other) const
+    {
+        return _row == other._row && _column == other._column;
+    }
+    inline bool operator!=(const CellReference &other) const
+    {
+        return _row != other._row || _column != other._column;
+    }
+
+private:
+    void init(const QString &cell);
+    int _row, _column;
+};
+
+QT_END_NAMESPACE_XLSX
+
+Q_DECLARE_TYPEINFO(QXlsx::CellReference, Q_MOVABLE_TYPE);
+
+#endif // QXLSX_XLSXCELLREFERENCE_H

+ 77 - 0
demo/xlsx/QXlsx/QXlsx/xlsxchart.h

@@ -0,0 +1,77 @@
+// xlsxchart.h
+
+#ifndef QXLSX_CHART_H
+#define QXLSX_CHART_H
+
+#include "xlsxabstractooxmlfile.h"
+
+#include <QXmlStreamReader>
+#include <QXmlStreamWriter>
+#include <QtGlobal>
+
+QT_BEGIN_NAMESPACE_XLSX
+
+class AbstractSheet;
+class Worksheet;
+class ChartPrivate;
+class CellRange;
+class DrawingAnchor;
+
+class QXLSX_EXPORT Chart : public AbstractOOXmlFile
+{
+    Q_DECLARE_PRIVATE(Chart)
+public:
+    enum ChartType {             // 16 type of chart (ECMA 376)
+        CT_NoStatementChart = 0, // Zero is internally used for unknown types
+        CT_AreaChart,
+        CT_Area3DChart,
+        CT_LineChart,
+        CT_Line3DChart,
+        CT_StockChart,
+        CT_RadarChart,
+        CT_ScatterChart,
+        CT_PieChart,
+        CT_Pie3DChart,
+        CT_DoughnutChart,
+        CT_BarChart,
+        CT_Bar3DChart,
+        CT_OfPieChart,
+        CT_SurfaceChart,
+        CT_Surface3DChart,
+        CT_BubbleChart,
+    };
+    enum ChartAxisPos { None = (-1), Left = 0, Right, Top, Bottom };
+
+private:
+    friend class AbstractSheet;
+    friend class Worksheet;
+    friend class Chartsheet;
+    friend class DrawingAnchor;
+
+private:
+    Chart(AbstractSheet *parent, CreateFlag flag);
+
+public:
+    ~Chart();
+
+public:
+    void addSeries(const CellRange &range,
+                   AbstractSheet *sheet = nullptr,
+                   bool headerH         = false,
+                   bool headerV         = false,
+                   bool swapHeaders     = false);
+    void setChartType(ChartType type);
+    void setChartStyle(int id);
+    void setAxisTitle(Chart::ChartAxisPos pos, QString axisTitle);
+    void setChartTitle(QString strchartTitle);
+    void setChartLegend(Chart::ChartAxisPos legendPos, bool overlap = false);
+    void setGridlinesEnable(bool majorGridlinesEnable = false, bool minorGridlinesEnable = false);
+
+public:
+    bool loadFromXmlFile(QIODevice *device) override;
+    void saveToXmlFile(QIODevice *device) const override;
+};
+
+QT_END_NAMESPACE_XLSX
+
+#endif // QXLSX_CHART_H

+ 38 - 0
demo/xlsx/QXlsx/QXlsx/xlsxchartsheet.h

@@ -0,0 +1,38 @@
+// xlsxchartsheet.h
+
+#ifndef XLSXCHARTSHEET_H
+#define XLSXCHARTSHEET_H
+
+#include "xlsxabstractsheet.h"
+
+#include <QStringList>
+#include <QtGlobal>
+
+QT_BEGIN_NAMESPACE_XLSX
+
+class Workbook;
+class DocumentPrivate;
+class ChartsheetPrivate;
+class Chart;
+
+class QXLSX_EXPORT Chartsheet : public AbstractSheet
+{
+    Q_DECLARE_PRIVATE(Chartsheet)
+
+public:
+    ~Chartsheet();
+    Chart *chart();
+
+private:
+    friend class DocumentPrivate;
+    friend class Workbook;
+
+    Chartsheet(const QString &sheetName, int sheetId, Workbook *book, CreateFlag flag);
+    Chartsheet *copy(const QString &distName, int distId) const override;
+
+    void saveToXmlFile(QIODevice *device) const override;
+    bool loadFromXmlFile(QIODevice *device) override;
+};
+
+QT_END_NAMESPACE_XLSX
+#endif // XLSXCHARTSHEET_H

+ 131 - 0
demo/xlsx/QXlsx/QXlsx/xlsxconditionalformatting.h

@@ -0,0 +1,131 @@
+// xlsxconditionalformatting.h
+
+#ifndef QXLSX_XLSXCONDITIONALFORMATTING_H
+#define QXLSX_XLSXCONDITIONALFORMATTING_H
+
+#include "xlsxcellrange.h"
+#include "xlsxcellreference.h"
+#include "xlsxglobal.h"
+
+#include <QColor>
+#include <QList>
+#include <QSharedDataPointer>
+#include <QString>
+#include <QXmlStreamReader>
+#include <QXmlStreamWriter>
+#include <QtGlobal>
+
+class ConditionalFormattingTest;
+
+QT_BEGIN_NAMESPACE_XLSX
+
+class Format;
+class Worksheet;
+class Styles;
+class ConditionalFormattingPrivate;
+
+class QXLSX_EXPORT ConditionalFormatting
+{
+public:
+    enum HighlightRuleType {
+        Highlight_LessThan,
+        Highlight_LessThanOrEqual,
+        Highlight_Equal,
+        Highlight_NotEqual,
+        Highlight_GreaterThanOrEqual,
+        Highlight_GreaterThan,
+        Highlight_Between,
+        Highlight_NotBetween,
+
+        Highlight_ContainsText,
+        Highlight_NotContainsText,
+        Highlight_BeginsWith,
+        Highlight_EndsWith,
+
+        Highlight_TimePeriod,
+
+        Highlight_Duplicate,
+        Highlight_Unique,
+        Highlight_Blanks,
+        Highlight_NoBlanks,
+        Highlight_Errors,
+        Highlight_NoErrors,
+
+        Highlight_Top,
+        Highlight_TopPercent,
+        Highlight_Bottom,
+        Highlight_BottomPercent,
+
+        Highlight_AboveAverage,
+        Highlight_AboveOrEqualAverage,
+        Highlight_AboveStdDev1,
+        Highlight_AboveStdDev2,
+        Highlight_AboveStdDev3,
+        Highlight_BelowAverage,
+        Highlight_BelowOrEqualAverage,
+        Highlight_BelowStdDev1,
+        Highlight_BelowStdDev2,
+        Highlight_BelowStdDev3,
+
+        Highlight_Expression
+    };
+
+    enum ValueObjectType { VOT_Formula, VOT_Max, VOT_Min, VOT_Num, VOT_Percent, VOT_Percentile };
+
+public:
+    ConditionalFormatting();
+    ConditionalFormatting(const ConditionalFormatting &other);
+    ~ConditionalFormatting();
+
+public:
+    bool addHighlightCellsRule(HighlightRuleType type,
+                               const Format &format,
+                               bool stopIfTrue = false);
+    bool addHighlightCellsRule(HighlightRuleType type,
+                               const QString &formula1,
+                               const Format &format,
+                               bool stopIfTrue = false);
+    bool addHighlightCellsRule(HighlightRuleType type,
+                               const QString &formula1,
+                               const QString &formula2,
+                               const Format &format,
+                               bool stopIfTrue = false);
+    bool addDataBarRule(const QColor &color, bool showData = true, bool stopIfTrue = false);
+    bool addDataBarRule(const QColor &color,
+                        ValueObjectType type1,
+                        const QString &val1,
+                        ValueObjectType type2,
+                        const QString &val2,
+                        bool showData   = true,
+                        bool stopIfTrue = false);
+    bool
+        add2ColorScaleRule(const QColor &minColor, const QColor &maxColor, bool stopIfTrue = false);
+    bool add3ColorScaleRule(const QColor &minColor,
+                            const QColor &midColor,
+                            const QColor &maxColor,
+                            bool stopIfTrue = false);
+
+    QList<CellRange> ranges() const;
+
+    void addCell(const CellReference &cell);
+    void addCell(int row, int col);
+    void addRange(int firstRow, int firstCol, int lastRow, int lastCol);
+    void addRange(const CellRange &range);
+
+    // needed by QSharedDataPointer!!
+    ConditionalFormatting &operator=(const ConditionalFormatting &other);
+
+private:
+    friend class Worksheet;
+    friend class ::ConditionalFormattingTest;
+
+private:
+    bool saveToXml(QXmlStreamWriter &writer) const;
+    bool loadFromXml(QXmlStreamReader &reader, Styles *styles = nullptr);
+
+    QSharedDataPointer<ConditionalFormattingPrivate> d;
+};
+
+QT_END_NAMESPACE_XLSX
+
+#endif // QXLSX_XLSXCONDITIONALFORMATTING_H

+ 93 - 0
demo/xlsx/QXlsx/QXlsx/xlsxdatavalidation.h

@@ -0,0 +1,93 @@
+// xlsxvalidation.h
+
+#ifndef QXLSX_XLSXDATAVALIDATION_H
+#define QXLSX_XLSXDATAVALIDATION_H
+
+#include "xlsxglobal.h"
+
+#include <QList>
+#include <QSharedDataPointer>
+#include <QString>
+#include <QXmlStreamReader>
+#include <QXmlStreamWriter>
+#include <QtGlobal>
+
+class QXmlStreamReader;
+class QXmlStreamWriter;
+
+QT_BEGIN_NAMESPACE_XLSX
+
+class Worksheet;
+class CellRange;
+class CellReference;
+
+class DataValidationPrivate;
+class QXLSX_EXPORT DataValidation
+{
+public:
+    enum ValidationType { None, Whole, Decimal, List, Date, Time, TextLength, Custom };
+
+    enum ValidationOperator {
+        Between,
+        NotBetween,
+        Equal,
+        NotEqual,
+        LessThan,
+        LessThanOrEqual,
+        GreaterThan,
+        GreaterThanOrEqual
+    };
+
+    enum ErrorStyle { Stop, Warning, Information };
+
+    DataValidation();
+    DataValidation(ValidationType type,
+                   ValidationOperator op   = Between,
+                   const QString &formula1 = QString(),
+                   const QString &formula2 = QString(),
+                   bool allowBlank         = false);
+    DataValidation(const DataValidation &other);
+    ~DataValidation();
+
+    ValidationType validationType() const;
+    ValidationOperator validationOperator() const;
+    ErrorStyle errorStyle() const;
+    QString formula1() const;
+    QString formula2() const;
+    bool allowBlank() const;
+    QString errorMessage() const;
+    QString errorMessageTitle() const;
+    QString promptMessage() const;
+    QString promptMessageTitle() const;
+    bool isPromptMessageVisible() const;
+    bool isErrorMessageVisible() const;
+    QList<CellRange> ranges() const;
+
+    void setValidationType(ValidationType type);
+    void setValidationOperator(ValidationOperator op);
+    void setErrorStyle(ErrorStyle es);
+    void setFormula1(const QString &formula);
+    void setFormula2(const QString &formula);
+    void setErrorMessage(const QString &error, const QString &title = QString());
+    void setPromptMessage(const QString &prompt, const QString &title = QString());
+    void setAllowBlank(bool enable);
+    void setPromptMessageVisible(bool visible);
+    void setErrorMessageVisible(bool visible);
+
+    void addCell(const CellReference &cell);
+    void addCell(int row, int col);
+    void addRange(int firstRow, int firstCol, int lastRow, int lastCol);
+    void addRange(const CellRange &range);
+
+    DataValidation &operator=(const DataValidation &other);
+
+    bool saveToXml(QXmlStreamWriter &writer) const;
+    static DataValidation loadFromXml(QXmlStreamReader &reader);
+
+private:
+    QSharedDataPointer<DataValidationPrivate> d;
+};
+
+QT_END_NAMESPACE_XLSX
+
+#endif // QXLSX_XLSXDATAVALIDATION_H

+ 48 - 0
demo/xlsx/QXlsx/QXlsx/xlsxdatetype.h

@@ -0,0 +1,48 @@
+// xlsxdatetype.h
+
+#ifndef QXLSX_XLSXDATETYPE_H
+#define QXLSX_XLSXDATETYPE_H
+
+#include "xlsxglobal.h"
+
+#include <QDate>
+#include <QDateTime>
+#include <QObject>
+#include <QString>
+#include <QStringList>
+#include <QTime>
+#include <QtGlobal>
+
+QT_BEGIN_NAMESPACE_XLSX
+
+class QXLSX_EXPORT DateType
+{
+public:
+    DateType();
+    /*
+        DateType(bool is1904 = false);
+        DateType(double d, bool is1904 = false);
+        DateType(QDateTime qdt, bool is1904 = false);
+        DateType(QDate qd, bool is1904 = false);
+        DateType(QTime qt, bool is1904 = false);
+    public:
+        enum currentDateType { DateAndTimeType, OnlyDateType, OnlyTimeType };
+    public:
+        currentDateType getType();
+        bool getValue(QDateTime* pQdt);
+        bool getValue(QDate* pQd);
+        bool getValue(QTime* pQt);
+        bool getValue(double* pD);
+
+    protected:
+
+    protected:
+        bool isSet;
+        double dValue;
+        bool is1904Type;
+        currentDateType dType;
+    */
+};
+
+QT_END_NAMESPACE_XLSX
+#endif

+ 145 - 0
demo/xlsx/QXlsx/QXlsx/xlsxdocument.h

@@ -0,0 +1,145 @@
+// xlsxdocument.h
+
+#ifndef QXLSX_XLSXDOCUMENT_H
+#define QXLSX_XLSXDOCUMENT_H
+
+#include "xlsxformat.h"
+#include "xlsxglobal.h"
+#include "xlsxworksheet.h"
+
+#include <QIODevice>
+#include <QImage>
+#include <QObject>
+#include <QVariant>
+#include <QtGlobal>
+
+QT_BEGIN_NAMESPACE_XLSX
+
+class Workbook;
+class Cell;
+class CellRange;
+class DataValidation;
+class ConditionalFormatting;
+class Chart;
+class CellReference;
+class DocumentPrivate;
+
+class QXLSX_EXPORT Document : public QObject
+{
+    Q_OBJECT
+    Q_DECLARE_PRIVATE(Document) // D-Pointer. Qt classes have a Q_DECLARE_PRIVATE
+                                // macro in the public class. The macro reads: qglobal.h
+public:
+    explicit Document(QObject *parent = nullptr);
+    Document(const QString &xlsxName, QObject *parent = nullptr);
+    Document(QIODevice *device, QObject *parent = nullptr);
+    ~Document();
+
+    bool write(const CellReference &cell, const QVariant &value, const Format &format = Format());
+    bool write(int row, int col, const QVariant &value, const Format &format = Format());
+
+    QVariant read(const CellReference &cell) const;
+    QVariant read(int row, int col) const;
+
+    int insertImage(int row, int col, const QImage &image);
+    bool getImage(int imageIndex, QImage &img);
+    bool getImage(int row, int col, QImage &img);
+    uint getImageCount();
+
+    Chart *insertChart(int row, int col, const QSize &size);
+
+    bool mergeCells(const CellRange &range, const Format &format = Format());
+    bool unmergeCells(const CellRange &range);
+
+    bool setColumnWidth(const CellRange &range, double width);
+    bool setColumnFormat(const CellRange &range, const Format &format);
+    bool setColumnHidden(const CellRange &range, bool hidden);
+    bool setColumnWidth(int column, double width);
+    bool setColumnFormat(int column, const Format &format);
+    bool setColumnHidden(int column, bool hidden);
+    bool setColumnWidth(int colFirst, int colLast, double width);
+    bool setColumnFormat(int colFirst, int colLast, const Format &format);
+    bool setColumnHidden(int colFirst, int colLast, bool hidden);
+
+    double columnWidth(int column);
+    Format columnFormat(int column);
+    bool isColumnHidden(int column);
+
+    bool setRowHeight(int row, double height);
+    bool setRowFormat(int row, const Format &format);
+    bool setRowHidden(int row, bool hidden);
+    bool setRowHeight(int rowFirst, int rowLast, double height);
+    bool setRowFormat(int rowFirst, int rowLast, const Format &format);
+    bool setRowHidden(int rowFirst, int rowLast, bool hidden);
+
+    double rowHeight(int row);
+    Format rowFormat(int row);
+    bool isRowHidden(int row);
+
+    bool groupRows(int rowFirst, int rowLast, bool collapsed = true);
+    bool groupColumns(int colFirst, int colLast, bool collapsed = true);
+
+    bool addDataValidation(const DataValidation &validation);
+    bool addConditionalFormatting(const ConditionalFormatting &cf);
+
+    Cell *cellAt(const CellReference &cell) const;
+    Cell *cellAt(int row, int col) const;
+
+    bool defineName(const QString &name,
+                    const QString &formula,
+                    const QString &comment = QString(),
+                    const QString &scope   = QString());
+
+    CellRange dimension() const;
+
+    QString documentProperty(const QString &name) const;
+    void setDocumentProperty(const QString &name, const QString &property);
+    QStringList documentPropertyNames() const;
+
+    QStringList sheetNames() const;
+    bool addSheet(const QString &name           = QString(),
+                  AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
+    bool insertSheet(int index,
+                     const QString &name           = QString(),
+                     AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
+    bool selectSheet(const QString &name);
+    bool selectSheet(int index);
+    bool renameSheet(const QString &oldName, const QString &newName);
+    bool copySheet(const QString &srcName, const QString &distName = QString());
+    bool moveSheet(const QString &srcName, int distIndex);
+    bool deleteSheet(const QString &name);
+
+    Workbook *workbook() const;
+    AbstractSheet *sheet(const QString &sheetName) const;
+    AbstractSheet *currentSheet() const;
+    Worksheet *currentWorksheet() const;
+
+    bool save() const;
+    bool saveAs(const QString &xlsXname) const;
+    bool saveAs(QIODevice *device) const;
+
+    // copy style from one xlsx file to other
+    static bool copyStyle(const QString &from, const QString &to);
+
+    bool isLoadPackage() const;
+    bool load() const; // equals to isLoadPackage()
+
+    bool changeimage(int filenoinmidea, QString newfile); // add by liufeijin20181025
+
+    bool autosizeColumnWidth(const CellRange &range);
+    bool autosizeColumnWidth(int column);
+    bool autosizeColumnWidth(int colFirst, int colLast);
+    bool autosizeColumnWidth(void);
+
+private:
+    QMap<int, int> getMaximalColumnWidth(int firstRow = 1, int lastRow = INT_MAX);
+
+private:
+    Q_DISABLE_COPY(Document) // Disables the use of copy constructors and
+                             // assignment operators for the given Class.
+    DocumentPrivate *const d_ptr;
+};
+
+QT_END_NAMESPACE_XLSX
+
+#endif // QXLSX_XLSXDOCUMENT_H

+ 255 - 0
demo/xlsx/QXlsx/QXlsx/xlsxformat.h

@@ -0,0 +1,255 @@
+// xlsxformat.h
+
+#ifndef QXLSX_FORMAT_H
+#define QXLSX_FORMAT_H
+
+#include "xlsxglobal.h"
+
+#include <QByteArray>
+#include <QColor>
+#include <QExplicitlySharedDataPointer>
+#include <QFont>
+#include <QList>
+#include <QVariant>
+
+class FormatTest;
+
+QT_BEGIN_NAMESPACE_XLSX
+
+class Styles;
+class Worksheet;
+class WorksheetPrivate;
+class RichStringPrivate;
+class SharedStrings;
+
+class FormatPrivate;
+
+class QXLSX_EXPORT Format
+{
+public:
+    enum FontScript { FontScriptNormal, FontScriptSuper, FontScriptSub };
+
+    enum FontUnderline {
+        FontUnderlineNone,
+        FontUnderlineSingle,
+        FontUnderlineDouble,
+        FontUnderlineSingleAccounting,
+        FontUnderlineDoubleAccounting
+    };
+
+    enum HorizontalAlignment {
+        AlignHGeneral,
+        AlignLeft,
+        AlignHCenter,
+        AlignRight,
+        AlignHFill,
+        AlignHJustify,
+        AlignHMerge,
+        AlignHDistributed
+    };
+
+    enum VerticalAlignment {
+        AlignTop,
+        AlignVCenter,
+        AlignBottom,
+        AlignVJustify,
+        AlignVDistributed
+    };
+
+    enum BorderStyle {
+        BorderNone,
+        BorderThin,
+        BorderMedium,
+        BorderDashed,
+        BorderDotted,
+        BorderThick,
+        BorderDouble,
+        BorderHair,
+        BorderMediumDashed,
+        BorderDashDot,
+        BorderMediumDashDot,
+        BorderDashDotDot,
+        BorderMediumDashDotDot,
+        BorderSlantDashDot
+    };
+
+    enum DiagonalBorderType {
+        DiagonalBorderNone,
+        DiagonalBorderDown,
+        DiagonalBorderUp,
+        DiagnoalBorderBoth
+    };
+
+    enum FillPattern {
+        PatternNone,
+        PatternSolid,
+        PatternMediumGray,
+        PatternDarkGray,
+        PatternLightGray,
+        PatternDarkHorizontal,
+        PatternDarkVertical,
+        PatternDarkDown,
+        PatternDarkUp,
+        PatternDarkGrid,
+        PatternDarkTrellis,
+        PatternLightHorizontal,
+        PatternLightVertical,
+        PatternLightDown,
+        PatternLightUp,
+        PatternLightTrellis,
+        PatternGray125,
+        PatternGray0625,
+        PatternLightGrid
+    };
+
+    Format();
+    Format(const Format &other);
+    Format &operator=(const Format &rhs);
+    ~Format();
+
+    int numberFormatIndex() const;
+    void setNumberFormatIndex(int format);
+    QString numberFormat() const;
+    void setNumberFormat(const QString &format);
+    void setNumberFormat(int id, const QString &format);
+    bool isDateTimeFormat() const;
+
+    int fontSize() const;
+    void setFontSize(int size);
+    bool fontItalic() const;
+    void setFontItalic(bool italic);
+    bool fontStrikeOut() const;
+    void setFontStrikeOut(bool);
+    QColor fontColor() const;
+    void setFontColor(const QColor &);
+    bool fontBold() const;
+    void setFontBold(bool bold);
+    FontScript fontScript() const;
+    void setFontScript(FontScript);
+    FontUnderline fontUnderline() const;
+    void setFontUnderline(FontUnderline);
+    bool fontOutline() const;
+    void setFontOutline(bool outline);
+    QString fontName() const;
+    void setFontName(const QString &);
+    QFont font() const;
+    void setFont(const QFont &font);
+
+    HorizontalAlignment horizontalAlignment() const;
+    void setHorizontalAlignment(HorizontalAlignment align);
+    VerticalAlignment verticalAlignment() const;
+    void setVerticalAlignment(VerticalAlignment align);
+    bool textWrap() const;
+    void setTextWrap(bool textWrap);
+    int rotation() const;
+    void setRotation(int rotation);
+    int indent() const;
+    void setIndent(int indent);
+    bool shrinkToFit() const;
+    void setShrinkToFit(bool shink);
+
+    void setBorderStyle(BorderStyle style);
+    void setBorderColor(const QColor &color);
+    BorderStyle leftBorderStyle() const;
+    void setLeftBorderStyle(BorderStyle style);
+    QColor leftBorderColor() const;
+    void setLeftBorderColor(const QColor &color);
+    BorderStyle rightBorderStyle() const;
+    void setRightBorderStyle(BorderStyle style);
+    QColor rightBorderColor() const;
+    void setRightBorderColor(const QColor &color);
+    BorderStyle topBorderStyle() const;
+    void setTopBorderStyle(BorderStyle style);
+    QColor topBorderColor() const;
+    void setTopBorderColor(const QColor &color);
+    BorderStyle bottomBorderStyle() const;
+    void setBottomBorderStyle(BorderStyle style);
+    QColor bottomBorderColor() const;
+    void setBottomBorderColor(const QColor &color);
+    BorderStyle diagonalBorderStyle() const;
+    void setDiagonalBorderStyle(BorderStyle style);
+    DiagonalBorderType diagonalBorderType() const;
+    void setDiagonalBorderType(DiagonalBorderType style);
+    QColor diagonalBorderColor() const;
+    void setDiagonalBorderColor(const QColor &color);
+
+    FillPattern fillPattern() const;
+    void setFillPattern(FillPattern pattern);
+    QColor patternForegroundColor() const;
+    void setPatternForegroundColor(const QColor &color);
+    QColor patternBackgroundColor() const;
+    void setPatternBackgroundColor(const QColor &color);
+
+    bool locked() const;
+    void setLocked(bool locked);
+    bool hidden() const;
+    void setHidden(bool hidden);
+
+    void mergeFormat(const Format &modifier);
+    bool isValid() const;
+    bool isEmpty() const;
+
+    bool operator==(const Format &format) const;
+    bool operator!=(const Format &format) const;
+
+    QVariant property(int propertyId, const QVariant &defaultValue = QVariant()) const;
+    void setProperty(int propertyId,
+                     const QVariant &value,
+                     const QVariant &clearValue = QVariant(),
+                     bool detach                = true);
+    void clearProperty(int propertyId);
+    bool hasProperty(int propertyId) const;
+
+    bool boolProperty(int propertyId, bool defaultValue = false) const;
+    int intProperty(int propertyId, int defaultValue = 0) const;
+    double doubleProperty(int propertyId, double defaultValue = 0.0) const;
+    QString stringProperty(int propertyId, const QString &defaultValue = QString()) const;
+    QColor colorProperty(int propertyId, const QColor &defaultValue = QColor()) const;
+
+    bool hasNumFmtData() const;
+    bool hasFontData() const;
+    bool hasFillData() const;
+    bool hasBorderData() const;
+    bool hasAlignmentData() const;
+    bool hasProtectionData() const;
+
+    bool fontIndexValid() const;
+    int fontIndex() const;
+    QByteArray fontKey() const;
+    bool borderIndexValid() const;
+    QByteArray borderKey() const;
+    int borderIndex() const;
+    bool fillIndexValid() const;
+    QByteArray fillKey() const;
+    int fillIndex() const;
+
+    QByteArray formatKey() const;
+    bool xfIndexValid() const;
+    int xfIndex() const;
+    bool dxfIndexValid() const;
+    int dxfIndex() const;
+
+    void fixNumberFormat(int id, const QString &format);
+    void setFontIndex(int index);
+    void setBorderIndex(int index);
+    void setFillIndex(int index);
+    void setXfIndex(int index);
+    void setDxfIndex(int index);
+
+private:
+    friend class Styles;
+    friend class ::FormatTest;
+    friend QDebug operator<<(QDebug, const Format &f);
+
+    int theme() const;
+
+    QExplicitlySharedDataPointer<FormatPrivate> d;
+};
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const Format &f);
+#endif
+
+QT_END_NAMESPACE_XLSX
+
+#endif // QXLSX_FORMAT_H

+ 33 - 0
demo/xlsx/QXlsx/QXlsx/xlsxglobal.h

@@ -0,0 +1,33 @@
+// xlsxglobal.h
+
+#ifndef XLSXGLOBAL_H
+#define XLSXGLOBAL_H
+
+#include <cstdio>
+#include <iostream>
+#include <string>
+
+#include <QByteArray>
+#include <QIODevice>
+#include <QObject>
+#include <QString>
+#include <QStringList>
+#include <QVariant>
+#include <QtGlobal>
+
+#if defined(QXlsx_SHAREDLIB)
+#    if defined(QXlsx_EXPORTS)
+#        define QXLSX_EXPORT Q_DECL_EXPORT
+#    else
+#        define QXLSX_EXPORT Q_DECL_IMPORT
+#    endif
+#else
+#    define QXLSX_EXPORT
+#endif
+
+#define QT_BEGIN_NAMESPACE_XLSX namespace QXlsx {
+#define QT_END_NAMESPACE_XLSX }
+
+#define QXLSX_USE_NAMESPACE using namespace QXlsx;
+
+#endif // XLSXGLOBAL_H

+ 91 - 0
demo/xlsx/QXlsx/QXlsx/xlsxrichstring.h

@@ -0,0 +1,91 @@
+/****************************************************************************
+** Copyright (c) 2013-2014 Debao Zhang <hello@debao.me>
+** All right reserved.
+**
+** Permission is hereby granted, free of charge, to any person obtaining
+** a copy of this software and associated documentation files (the
+** "Software"), to deal in the Software without restriction, including
+** without limitation the rights to use, copy, modify, merge, publish,
+** distribute, sublicense, and/or sell copies of the Software, and to
+** permit persons to whom the Software is furnished to do so, subject to
+** the following conditions:
+**
+** The above copyright notice and this permission notice shall be
+** included in all copies or substantial portions of the Software.
+**
+** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+** NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+** LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+** OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+** WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+**
+****************************************************************************/
+#ifndef XLSXRICHSTRING_H
+#define XLSXRICHSTRING_H
+
+#include "xlsxformat.h"
+#include "xlsxglobal.h"
+
+#include <QSharedDataPointer>
+#include <QStringList>
+#include <QVariant>
+
+QT_BEGIN_NAMESPACE_XLSX
+class RichStringPrivate;
+class RichString;
+// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4)
+uint qHash(const RichString &rs, uint seed = 0) Q_DECL_NOTHROW;
+
+class QXLSX_EXPORT RichString
+{
+public:
+    RichString();
+    explicit RichString(const QString &text);
+    RichString(const RichString &other);
+    ~RichString();
+
+    bool isRichString() const;
+    bool isNull() const;
+    bool isEmtpy() const;
+    QString toPlainString() const;
+    QString toHtml() const;
+    void setHtml(const QString &text);
+
+    int fragmentCount() const;
+    void addFragment(const QString &text, const Format &format);
+    QString fragmentText(int index) const;
+    Format fragmentFormat(int index) const;
+
+    operator QVariant() const;
+
+    RichString &operator=(const RichString &other);
+
+private:
+    friend uint qHash(const RichString &rs, uint seed) Q_DECL_NOTHROW;
+    friend bool operator==(const RichString &rs1, const RichString &rs2);
+    friend bool operator!=(const RichString &rs1, const RichString &rs2);
+    friend bool operator<(const RichString &rs1, const RichString &rs2);
+    friend QDebug operator<<(QDebug dbg, const RichString &rs);
+
+    QSharedDataPointer<RichStringPrivate> d;
+};
+
+bool operator==(const RichString &rs1, const RichString &rs2);
+bool operator!=(const RichString &rs1, const RichString &rs2);
+bool operator<(const RichString &rs1, const RichString &rs2);
+bool operator==(const RichString &rs1, const QString &rs2);
+bool operator==(const QString &rs1, const RichString &rs2);
+bool operator!=(const RichString &rs1, const QString &rs2);
+bool operator!=(const QString &rs1, const RichString &rs2);
+
+#ifndef QT_NO_DEBUG_STREAM
+QDebug operator<<(QDebug dbg, const RichString &rs);
+#endif
+
+QT_END_NAMESPACE_XLSX
+
+Q_DECLARE_METATYPE(QXlsx::RichString)
+
+#endif // XLSXRICHSTRING_H

+ 103 - 0
demo/xlsx/QXlsx/QXlsx/xlsxworkbook.h

@@ -0,0 +1,103 @@
+// xlsxworkbook.h
+
+#ifndef XLSXWORKBOOK_H
+#define XLSXWORKBOOK_H
+
+#include "xlsxabstractooxmlfile.h"
+#include "xlsxabstractsheet.h"
+#include "xlsxglobal.h"
+
+#include <memory>
+
+#include <QIODevice>
+#include <QImage>
+#include <QList>
+#include <QSharedPointer>
+#include <QtGlobal>
+
+QT_BEGIN_NAMESPACE_XLSX
+
+class SharedStrings;
+class Styles;
+class Drawing;
+class Document;
+class Theme;
+class Relationships;
+class DocumentPrivate;
+class MediaFile;
+class Chart;
+class Chartsheet;
+class Worksheet;
+class WorkbookPrivate;
+
+class QXLSX_EXPORT Workbook : public AbstractOOXmlFile
+{
+    Q_DECLARE_PRIVATE(Workbook)
+public:
+    ~Workbook();
+
+    int sheetCount() const;
+    AbstractSheet *sheet(int index) const;
+
+    AbstractSheet *addSheet(const QString &name           = QString(),
+                            AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
+    AbstractSheet *insertSheet(int index,
+                               const QString &name           = QString(),
+                               AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
+    bool renameSheet(int index, const QString &name);
+    bool deleteSheet(int index);
+    bool copySheet(int index, const QString &newName = QString());
+    bool moveSheet(int srcIndex, int distIndex);
+
+    AbstractSheet *activeSheet() const;
+    bool setActiveSheet(int index);
+
+    //    void addChart();
+    bool defineName(const QString &name,
+                    const QString &formula,
+                    const QString &comment = QString(),
+                    const QString &scope   = QString());
+    bool isDate1904() const;
+    void setDate1904(bool date1904);
+    bool isStringsToNumbersEnabled() const;
+    void setStringsToNumbersEnabled(bool enable = true);
+    bool isStringsToHyperlinksEnabled() const;
+    void setStringsToHyperlinksEnabled(bool enable = true);
+    bool isHtmlToRichStringEnabled() const;
+    void setHtmlToRichStringEnabled(bool enable = true);
+    QString defaultDateFormat() const;
+    void setDefaultDateFormat(const QString &format);
+
+    // internal used member
+    void addMediaFile(std::shared_ptr<MediaFile> media, bool force = false);
+    QList<std::shared_ptr<MediaFile>> mediaFiles() const;
+    void addChartFile(QSharedPointer<Chart> chartFile);
+    QList<QSharedPointer<Chart>> chartFiles() const;
+
+private:
+    friend class Worksheet;
+    friend class Chartsheet;
+    friend class WorksheetPrivate;
+    friend class Document;
+    friend class DocumentPrivate;
+
+    Workbook(Workbook::CreateFlag flag);
+
+    void saveToXmlFile(QIODevice *device) const override;
+    bool loadFromXmlFile(QIODevice *device) override;
+
+    SharedStrings *sharedStrings() const;
+    Styles *styles();
+    Theme *theme();
+    QList<QImage> images();
+    QList<Drawing *> drawings();
+    QList<QSharedPointer<AbstractSheet>> getSheetsByTypes(AbstractSheet::SheetType type) const;
+    QStringList worksheetNames() const;
+    AbstractSheet *addSheet(const QString &name,
+                            int sheetId,
+                            AbstractSheet::SheetType type = AbstractSheet::ST_WorkSheet);
+};
+
+QT_END_NAMESPACE_XLSX
+
+#endif // XLSXWORKBOOK_H

+ 198 - 0
demo/xlsx/QXlsx/QXlsx/xlsxworksheet.h

@@ -0,0 +1,198 @@
+// xlsxworksheet.h
+
+#ifndef XLSXWORKSHEET_H
+#define XLSXWORKSHEET_H
+
+#include "xlsxabstractsheet.h"
+#include "xlsxcell.h"
+#include "xlsxcelllocation.h"
+#include "xlsxcellrange.h"
+#include "xlsxcellreference.h"
+
+#include <QDateTime>
+#include <QIODevice>
+#include <QImage>
+#include <QMap>
+#include <QObject>
+#include <QPointF>
+#include <QStringList>
+#include <QUrl>
+#include <QVariant>
+#include <QtGlobal>
+
+class WorksheetTest;
+
+QT_BEGIN_NAMESPACE_XLSX
+
+class DocumentPrivate;
+class Workbook;
+class Format;
+class Drawing;
+class DataValidation;
+class ConditionalFormatting;
+class CellRange;
+class RichString;
+class Relationships;
+class Chart;
+
+class WorksheetPrivate;
+class QXLSX_EXPORT Worksheet : public AbstractSheet
+{
+    Q_DECLARE_PRIVATE(Worksheet)
+
+private:
+    friend class DocumentPrivate;
+    friend class Workbook;
+    friend class ::WorksheetTest;
+    Worksheet(const QString &sheetName, int sheetId, Workbook *book, CreateFlag flag);
+    Worksheet *copy(const QString &distName, int distId) const override;
+
+public:
+    ~Worksheet();
+
+public:
+    bool write(const CellReference &row_column,
+               const QVariant &value,
+               const Format &format = Format());
+    bool write(int row, int column, const QVariant &value, const Format &format = Format());
+
+    QVariant read(const CellReference &row_column) const;
+    QVariant read(int row, int column) const;
+
+    bool writeString(const CellReference &row_column,
+                     const QString &value,
+                     const Format &format = Format());
+    bool writeString(int row, int column, const QString &value, const Format &format = Format());
+    bool writeString(const CellReference &row_column,
+                     const RichString &value,
+                     const Format &format = Format());
+    bool writeString(int row, int column, const RichString &value, const Format &format = Format());
+
+    bool writeInlineString(const CellReference &row_column,
+                           const QString &value,
+                           const Format &format = Format());
+    bool writeInlineString(int row,
+                           int column,
+                           const QString &value,
+                           const Format &format = Format());
+
+    bool writeNumeric(const CellReference &row_column,
+                      double value,
+                      const Format &format = Format());
+    bool writeNumeric(int row, int column, double value, const Format &format = Format());
+
+    bool writeFormula(const CellReference &row_column,
+                      const CellFormula &formula,
+                      const Format &format = Format(),
+                      double result        = 0);
+    bool writeFormula(int row,
+                      int column,
+                      const CellFormula &formula,
+                      const Format &format = Format(),
+                      double result        = 0);
+
+    bool writeBlank(const CellReference &row_column, const Format &format = Format());
+    bool writeBlank(int row, int column, const Format &format = Format());
+
+    bool writeBool(const CellReference &row_column, bool value, const Format &format = Format());
+    bool writeBool(int row, int column, bool value, const Format &format = Format());
+
+    bool writeDateTime(const CellReference &row_column,
+                       const QDateTime &dt,
+                       const Format &format = Format());
+    bool writeDateTime(int row, int column, const QDateTime &dt, const Format &format = Format());
+
+    // dev67
+    bool writeDate(const CellReference &row_column,
+                   const QDate &dt,
+                   const Format &format = Format());
+    bool writeDate(int row, int column, const QDate &dt, const Format &format = Format());
+
+    bool
+        writeTime(const CellReference &row_column, const QTime &t, const Format &format = Format());
+    bool writeTime(int row, int column, const QTime &t, const Format &format = Format());
+
+    bool writeHyperlink(const CellReference &row_column,
+                        const QUrl &url,
+                        const Format &format   = Format(),
+                        const QString &display = QString(),
+                        const QString &tip     = QString());
+    bool writeHyperlink(int row,
+                        int column,
+                        const QUrl &url,
+                        const Format &format   = Format(),
+                        const QString &display = QString(),
+                        const QString &tip     = QString());
+
+    bool addDataValidation(const DataValidation &validation);
+    bool addConditionalFormatting(const ConditionalFormatting &cf);
+
+    Cell *cellAt(const CellReference &row_column) const;
+    Cell *cellAt(int row, int column) const;
+
+    int insertImage(int row, int column, const QImage &image);
+    bool getImage(int imageIndex, QImage &img);
+    bool getImage(int row, int column, QImage &img);
+    uint getImageCount();
+
+    Chart *insertChart(int row, int column, const QSize &size);
+
+    bool mergeCells(const CellRange &range, const Format &format = Format());
+    bool unmergeCells(const CellRange &range);
+    QList<CellRange> mergedCells() const;
+
+    bool setColumnWidth(const CellRange &range, double width);
+    bool setColumnFormat(const CellRange &range, const Format &format);
+    bool setColumnHidden(const CellRange &range, bool hidden);
+    bool setColumnWidth(int colFirst, int colLast, double width);
+    bool setColumnFormat(int colFirst, int colLast, const Format &format);
+    bool setColumnHidden(int colFirst, int colLast, bool hidden);
+
+    double columnWidth(int column);
+    Format columnFormat(int column);
+    bool isColumnHidden(int column);
+
+    bool setRowHeight(int rowFirst, int rowLast, double height);
+    bool setRowFormat(int rowFirst, int rowLast, const Format &format);
+    bool setRowHidden(int rowFirst, int rowLast, bool hidden);
+
+    double rowHeight(int row);
+    Format rowFormat(int row);
+    bool isRowHidden(int row);
+
+    bool groupRows(int rowFirst, int rowLast, bool collapsed = true);
+    bool groupColumns(int colFirst, int colLast, bool collapsed = true);
+    bool groupColumns(const CellRange &range, bool collapsed = true);
+    CellRange dimension() const;
+
+    bool isWindowProtected() const;
+    void setWindowProtected(bool protect);
+    bool isFormulasVisible() const;
+    void setFormulasVisible(bool visible);
+    bool isGridLinesVisible() const;
+    void setGridLinesVisible(bool visible);
+    bool isRowColumnHeadersVisible() const;
+    void setRowColumnHeadersVisible(bool visible);
+    bool isZerosVisible() const;
+    void setZerosVisible(bool visible);
+    bool isRightToLeft() const;
+    void setRightToLeft(bool enable);
+    bool isSelected() const;
+    void setSelected(bool select);
+    bool isRulerVisible() const;
+    void setRulerVisible(bool visible);
+    bool isOutlineSymbolsVisible() const;
+    void setOutlineSymbolsVisible(bool visible);
+    bool isWhiteSpaceVisible() const;
+    void setWhiteSpaceVisible(bool visible);
+    bool setStartPage(int spagen); // add by liufeijin20181028
+
+    QVector<CellLocation> getFullCells(int *maxRow, int *maxCol);
+
+private:
+    void saveToXmlFile(QIODevice *device) const override;
+    bool loadFromXmlFile(QIODevice *device) override;
+};
+
+QT_END_NAMESPACE_XLSX
+#endif // XLSXWORKSHEET_H

BIN
demo/xlsx/QXlsx/debug/libQXlsx.a


+ 19 - 0
demo/xlsx/QXlsx/demo.txt

@@ -0,0 +1,19 @@
+	QXlsx::Document xlsxW;
+        if (!xlsxW.addSheet(action)) {
+            LH_WRITE_COMMON(action+"导出,创建表格失败!");
+            return;
+        }
+        // 写入导出列名称,第一行第一列开始
+        for (int i = 0; i < exportColsName.count(); ++i) {
+            xlsxW.write(1, i + 1, exportColsName.at(i));
+        }
+        // 写入内容信息,第二行第一列开始
+        for (int i = 0; i < outPutDataList.count(); ++i) {
+            for (int j = 0; j < outPutDataList.at(i).count(); ++j) {
+                xlsxW.write(2 + i, j + 1, outPutDataList.at(i).at(j));
+            }
+            progressValue = std::ceil(double(i+1)/double(outPutDataList.count())*100.0);
+            emit setProgressValue(progressValue);
+            QThread::msleep(10);
+        };
+        xlsxW.saveAs(saveFilePath);

BIN
demo/xlsx/QXlsx/release/libQXlsx.a


+ 22 - 0
demo/xlsx/main.cpp

@@ -0,0 +1,22 @@
+#include "widget.h"
+
+#include <QApplication>
+#include "Logs/loginit.h"
+#include "spdlog/spdlog.h"
+#include "FmtLog/fmtlog.h"
+
+
+int main(int argc, char *argv[])
+{
+    QApplication a(argc, argv);
+    init_log();
+
+    SPDLOG_INFO("********** Xlsx **********");
+
+
+
+    Widget w;
+    w.show();
+
+    return a.exec();
+}

+ 35 - 0
demo/xlsx/widget.cpp

@@ -0,0 +1,35 @@
+#include "widget.h"
+#include "./ui_widget.h"
+
+#include <QTimer>
+#include <QFileDialog>
+
+#include "spdlog/spdlog.h"
+
+#include "QXlsl/QXlsx/xlsxdocument.h"
+
+
+Widget::Widget(QWidget *parent)
+    : QWidget(parent)
+    , ui(new Ui::Widget)
+{
+    ui->setupUi(this);
+
+    
+    SPDLOG_INFO("***** Qt Library *****");
+    
+}
+
+Widget::~Widget()
+{
+
+    delete ui;
+}
+
+
+void Widget::on_pBtn_export_clicked()
+{
+    SPDLOG_INFO("点击了“导出excel”按钮");
+
+    
+}

+ 27 - 0
demo/xlsx/widget.h

@@ -0,0 +1,27 @@
+#ifndef WIDGET_H
+#define WIDGET_H
+
+#include <QWidget>
+
+QT_BEGIN_NAMESPACE
+namespace Ui { class Widget; }
+QT_END_NAMESPACE
+
+class Widget : public QWidget
+{
+    Q_OBJECT
+
+public:
+    Widget(QWidget *parent = nullptr);
+    ~Widget();
+
+private slots:
+
+    void on_pBtn_export_clicked();
+
+    
+private:
+    Ui::Widget *ui;
+
+};
+#endif // WIDGET_H

+ 49 - 0
demo/xlsx/widget.ui

@@ -0,0 +1,49 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>Widget</class>
+ <widget class="QWidget" name="Widget">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>1600</width>
+    <height>900</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>Widget</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <item>
+    <widget class="QWidget" name="widget_pBtn" native="true">
+     <property name="sizePolicy">
+      <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+       <horstretch>0</horstretch>
+       <verstretch>0</verstretch>
+      </sizepolicy>
+     </property>
+     <property name="minimumSize">
+      <size>
+       <width>1200</width>
+       <height>200</height>
+      </size>
+     </property>
+     <layout class="QGridLayout" name="gridLayout">
+      <item row="0" column="0">
+       <widget class="QPushButton" name="pBtn_export">
+        <property name="text">
+         <string>导出excel</string>
+        </property>
+       </widget>
+      </item>
+     </layout>
+    </widget>
+   </item>
+   <item>
+    <widget class="QWidget" name="widget_display" native="true"/>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections/>
+</ui>