dbzhang800 / QtXlsxWriter

.xlsx file reader and writer for Qt5
http://qtxlsx.debao.me
Other
1.23k stars 631 forks source link

Documentation: http://qtxlsx.debao.me

QtXlsx is a library that can read and write Excel files. It doesn't require Microsoft Excel and can be used in any platform that Qt5 supported. The library can be used to

Getting Started

  • For linux user, if your Qt is installed through package manager tools such "apt-get", make sure that you have installed the Qt5 develop package qtbase5-private-dev

Usage(1): Use Xlsx as Qt5's addon module

Building the module

Note: Perl is needed in this step.

    qmake
    make
    make install

The library, the header files, and others will be installed to your system.

make html_docs can be used to generate documentations of the library, and make check can be used to run unit tests of the library.

Using the module

    QT += xlsx
    #include <QtXlsx>
    int main()
    {
        QXlsx::Document xlsx;
        xlsx.write("A1", "Hello Qt!");
        xlsx.saveAs("Test.xlsx");
        return 0;
    }

Usage(2): Use source code directly

The package contains a qtxlsx.pri file that allows you to integrate the component into applications that use qmake for the build step.

    |-- project.pro
    |-- ....
    |-- 3rdparty\
    |     |-- qtxlsx\
    |     |
    include(3rdparty/qtxlsx/src/xlsx/qtxlsx.pri)

Note: If you like, you can copy all files from src/xlsx to your application's source path. Then add following line to your project file:

include(qtxlsx.pri)

Note: If you do not use qmake, you need to define the following macro manually

XLSX_NO_LIB
    #include "xlsxdocument.h"
    int main()
    {
        QXlsx::Document xlsx;
        xlsx.write("A1", "Hello Qt!");
        xlsx.saveAs("Test.xlsx");
        return 0;
    }

References

General

Number formats

Formula