This commit is contained in:
Herwig Birke
2018-01-30 16:48:23 +01:00
parent 7d218d38d5
commit cd0d3f76ad
16 changed files with 899 additions and 0 deletions
+6
View File
@@ -0,0 +1,6 @@
#Workaround for Issue #60
CONFIG += git_build
load(qt_build_config)
MODULE_VERSION = 0.3.0
+88
View File
@@ -0,0 +1,88 @@
cmake_minimum_required(VERSION 3.2)
project(QtXlsxWriter)
add_definitions(-DQT_BUILD_XLSX_LIB)
set(BUILD_SHARED_LIBS TRUE)
set(CMAKE_AUTOMOC ON)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()
file(
GLOB
QtXlsxWriter_SOURCE_FILES
${CMAKE_CURRENT_SOURCE_DIR}/src/xlsx/*.cpp
${CMAKE_CURRENT_BINARY_DIR}/QtXlsxWriterTest_automoc.cpp
)
find_package(Qt5 5.5 REQUIRED Core Gui Test)
include_directories(
${CMAKE_CURRENT_SOURCE_DIR}/src/xlsx/
${Qt5Core_INCLUDE_DIRS}
${Qt5Gui_INCLUDE_DIRS}
${Qt5Gui_PRIVATE_INCLUDE_DIRS} )
add_library(QtXlsxWriter SHARED "${QtXlsxWriter_SOURCE_FILES}")
# automatically add C++11 support with GCC
if(NOT MSVC)
target_compile_features(QtXlsxWriter PRIVATE cxx_range_for)
endif()
set_target_properties(QtXlsxWriter PROPERTIES DEBUG_POSTFIX "d")
target_link_libraries(QtXlsxWriter ${Qt5Core_LIBRARIES})
target_link_libraries(QtXlsxWriter ${Qt5Gui_LIBRARIES})
if(BUILD_TESTING)
add_subdirectory(tests)
endif()
if(BUILD_EXAMPLES)
add_custom_command(TARGET QtXlsxWriter POST_BUILD
COMMAND ${CMAKE_COMMAND}
-E copy_directory $<CONFIGURATION> ${CMAKE_CURRENT_BINARY_DIR}/examples/xlsx/$<CONFIGURATION>)
add_subdirectory(examples/xlsx)
endif()
##
#
# QtxlsxwriterVersion.cmake creation
#
##
set(QtXlsxWriter_CONFIG_PATH ${CMAKE_INSTALL_PREFIX})
configure_file(QtXlsxWriterConfig.cmake.in QtXlsxWriterConfig.cmake @ONLY)
#####
#
# Installation configuration
#
#####
INSTALL(TARGETS QtXlsxWriter
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
)
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtXlsxWriterConfig.cmake DESTINATION lib/cmake/${PROJECT_NAME})
SET(INCLUDE_FILES
src/xlsx/xlsxabstractooxmlfile.h
src/xlsx/xlsxabstractsheet.h
src/xlsx/xlsxcell.h
src/xlsx/xlsxcellformula.h
src/xlsx/xlsxcellrange.h
src/xlsx/xlsxcellreference.h
src/xlsx/xlsxchart.h
src/xlsx/xlsxchartsheet.h
src/xlsx/xlsxconditionalformatting.h
src/xlsx/xlsxdatavalidation.h
src/xlsx/xlsxdocument.h
src/xlsx/xlsxformat.h
src/xlsx/xlsxglobal.h
src/xlsx/xlsxrichstring.h
src/xlsx/xlsxworkbook.h
src/xlsx/xlsxworksheet.h
)
INSTALL(FILES ${INCLUDE_FILES} DESTINATION include)
+40
View File
@@ -0,0 +1,40 @@
#########################################
#
# Cmake QtXlsxWriter configuration file
#
# Usage from an external project:
# In your CMakeLists.txt, add these lines:
#
# FIND_PACKAGE(QtXlsxWriter REQUIRED)
# TARGET_LINK_LIBRARIES(MY_TARGET_NAME ${QtXlsxWriter_LIBS})
#
# This file will define the following variables:
#
# - QtXlsxWriter_BIN : The list of libraries to link against (.DLL, .SO).
# - QtXlsxWriter_LIBS : The list of libraries to link against (LIB, .A).
# - QtXlsxWriter_LIB_DIR : The directory(es) where lib files are. Calling LINK_DIRECTORIES
# with this path is NOT needed.
# - QtXlsxWriter_INCLUDE_DIRS : The QtXlsxWriter include directories (automatically added)
#
#########################################
if(CMAKE_VERSION VERSION_GREATER 2.6.2)
unset(QtXlsxWriter_CONFIG_PATH CACHE)
endif()
set(QtXlsxWriter_CONFIG_PATH "@QtXlsxWriter_CONFIG_PATH@")
set(QtXlsxWriter_FOUND TRUE CACHE BOOL "" FORCE)
set(QtXlsxWriter_LIBS QtXlsxWriter)
set(QtXlsxWriter_LIB_BIN ${QtXlsxWriter_CONFIG_PATH}/bin)
set(QtXlsxWriter_LIB_DIR ${QtXlsxWriter_CONFIG_PATH}/lib)
set(QtXlsxWriter_INCLUDE_DIRS ${QtXlsxWriter_CONFIG_PATH}/include)
include_directories(BEFORE ${QtXlsxWriter_INCLUDE_DIRS})
link_directories( ${LINK_DIRECTORIES} ${QtXlsxWriter_LIB_DIR} )
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args( QtXlsxWriter DEFAULT_MSG
QtXlsxWriter_LIBS QtXlsxWriter_INCLUDE_DIRS)
mark_as_advanced(FORCE QtXlsxWriter_LIBS QtXlsxWriter_LIB_DIR QtXlsxWriter_INCLUDE_DIRS)
+135
View File
@@ -0,0 +1,135 @@
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
* Generate a new .xlsx file from scratch
* Extract data from an existing .xlsx file
* Edit an existing .xlsx file
## 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.
* Download the source code.
* Put the source code in any directory you like
* Go to top directory of the project in a terminal and run
```
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
* Add following line to your qmake's project file:
```
QT += xlsx
```
* Then, using Qt Xlsx in your code
```cpp
#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.
* Download the source code.
* Put the source code in any directory you like. For example, 3rdparty:
```
|-- project.pro
|-- ....
|-- 3rdparty\
| |-- qtxlsx\
| |
```
* Add following line to your qmake project file:
```
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
```
* Then, using Qt Xlsx in your code
```cpp
#include "xlsxdocument.h"
int main()
{
QXlsx::Document xlsx;
xlsx.write("A1", "Hello Qt!");
xlsx.saveAs("Test.xlsx");
return 0;
}
```
## References
* http://www.ecma-international.org/publications/standards/Ecma-376.htm
* http://www.iso.org/iso/catalogue_detail?csnumber=51463
* http://msdn.microsoft.com/en-us/library/ee908652%28v=office.12%29.aspx
* http://www.datypic.com/sc/ooxml/
### General
* https://github.com/jmcnamara/XlsxWriter
* http://openpyxl.readthedocs.org
* http://officeopenxml.com/anatomyofOOXML-xlsx.php
* http://www.libxl.com
* http://closedxml.codeplex.com/
* http://epplus.codeplex.com/
* http://excelpackage.codeplex.com/
* http://spreadsheetlight.com/
### Number formats
* http://msdn.microsoft.com/en-us/library/ff529356%28v=office.12%29.aspx
* http://www.ozgrid.com/Excel/excel-custom-number-formats.htm
* http://stackoverflow.com/questions/894805/excel-number-format-what-is-409
* http://office.microsoft.com/en-001/excel-help/create-a-custom-number-format-HP010342372.aspx
### Formula
* http://msdn.microsoft.com/en-us/library/ff533995%28v=office.12%29.aspx
* http://msdn.microsoft.com/en-us/library/dd906358%28v=office.12%29.aspx
* http://homepages.ecs.vuw.ac.nz/~elvis/db/Excel.shtml
* http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html
+1
View File
@@ -0,0 +1 @@
load(qt_parts)
+3
View File
@@ -0,0 +1,3 @@
TEMPLATE = subdirs
SUBDIRS = xlsx
+75
View File
@@ -0,0 +1,75 @@
include($QT_INSTALL_DOCS/global/qt-html-templates-offline.qdocconf)
include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf)
project = QtXlsx
description = Qt Xlsx Reference Documentation
url = http://qtxlsx.debao.me
version = $QT_VERSION
qhp.projects = QtXlsx
qhp.QtXlsx.file = qtxlsx.qhp
qhp.QtXlsx.namespace = me.debao.qtxlsx.$QT_VERSION_TAG
qhp.QtXlsx.virtualFolder = qtxlsx
qhp.QtXlsx.indexTitle = Qt Xlsx
qhp.QtXlsx.indexRoot =
qhp.QtXlsx.filterAttributes = qtxlsx $QT_VERSION qtrefdoc
qhp.QtXlsx.customFilters.Qt.name = QtXlsx $QT_VERSION
qhp.QtXlsx.customFilters.Qt.filterAttributes = qtxlsx $QT_VERSION
qhp.QtXlsx.subprojects = overviews classes qmltypes examples
qhp.QtXlsx.subprojects.overviews.title = Overview
qhp.QtXlsx.subprojects.overviews.indexTitle = Qt Xlsx
qhp.QtXlsx.subprojects.overviews.selectors = fake:page,group,module
qhp.QtXlsx.subprojects.classes.title = C++ Classes
qhp.QtXlsx.subprojects.classes.indexTitle = Qt Xlsx C++ Classes
qhp.QtXlsx.subprojects.classes.selectors = class fake:headerfile
qhp.QtXlsx.subprojects.classes.sortPages = true
qhp.QtXlsx.subprojects.examples.title = Examples
qhp.QtXlsx.subprojects.examples.indexTitle = Qt Xlsx Examples
qhp.QtXlsx.subprojects.examples.selectors = fake:example
tagfile = ../../../doc/qtxlsx/qtxlsx.tags
headerdirs += ..
sourcedirs += ..
exampledirs += ../../../examples/xlsx \
snippets/
# Specify the install path under QT_INSTALL_EXAMPLES
examplesinstallpath = xlsx
imagedirs += images
depends += qtcore qtdoc qtgui
HTML.footer = \
" </div>\n" \
" </div>\n" \
" </div>\n" \
" </div>\n" \
"</div>\n" \
"<div class=\"footer\">\n" \
" <div class=\"qt13a-copyright\" id=\"copyright\">\n" \
" <div class=\"qt13a-container\">\n" \
" <p>\n" \
" <acronym title=\"Copyright\">&copy;</acronym> 2013-2014 Debao Zhang. \n" \
" Documentation contributions included herein are the copyrights of\n" \
" their respective owners.</p>\n" \
" <p>\n" \
" The documentation provided herein is licensed under the terms of the\n" \
" <a href=\"http://www.gnu.org/licenses/fdl.html\">GNU Free Documentation\n" \
" License version 1.3</a> as published by the Free Software Foundation.</p>\n" \
" <p>\n" \
" Documentation sources may be obtained from <a href=\"https://github.com/dbzhang800/QtXlsxWriter\">\n" \
" github.com/dbzhang800</a>.</p>\n" \
" <p>\n" \
" Qt and their respective logos are trademarks of Digia Plc \n" \
" in Finland and/or other countries worldwide. All other trademarks are property\n" \
" of their respective owners. <a title=\"Privacy Policy\"\n" \
" href=\"http://en.gitorious.org/privacy_policy/\">Privacy Policy</a></p>\n" \
" </div>\n" \
" </div>\n" \
"</div>\n" \
@@ -0,0 +1,8 @@
//! [0]
#include <QtXlsx>
//! [0]
//! [1]
#include <QtXlsx>
//! [1]
@@ -0,0 +1,3 @@
#! [1]
QT += xlsx
#! [1]
+8
View File
@@ -0,0 +1,8 @@
/*!
\group qtxlsx-examples
\title Qt Xlsx Examples
\brief Examples for the Qt Xlsx module
\ingroup all-examples
Qt Xlsx comes with the following examples:
*/
+72
View File
@@ -0,0 +1,72 @@
/****************************************************************************
** Copyright (c) 2013 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.
**
****************************************************************************/
/*!
\title Qt Xlsx
\page index.html
\brief Qt Xlsx provides functionality for handling .xlsx files.
The \l{Qt Xlsx C++ Classes}{Qt Xlsx Module} provides a set of classes to 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
\list
\li \l{Hello QtXlsx Example}{Generate a new .xlsx file from scratch}
\li \l{Extract Data Example}{Extract data from an existing .xlsx file}
\li Edit an existing .xlsx file
\endlist
\image xlsx_demo.gif
\table
\row
\li Source code: \li \l{https://github.com/dbzhang800/QtXlsxWriter}
\row
\li Issures: \li \l{https://github.com/dbzhang800/QtXlsxWriter/issues}
\row
\li License: \li MIT
\endtable
\section1 Getting Started
To include the definitions of the module's classes, using the following directive:
\code
#include <QtXlsx>
\endcode
To link against the module, add this line to your qmake .pro file:
\code
QT += xlsx
\endcode
More information can be found in \l{Qt Xlsx Build} page.
\section1 Related information
\list
\li \l{Qt Xlsx C++ Classes}
\li \l{Qt Xlsx Examples}
\endlist
*/
+36
View File
@@ -0,0 +1,36 @@
/****************************************************************************
** Copyright (c) 2013 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.
**
****************************************************************************/
/*!
\module QtXlsx
\title Qt Xlsx C++ Classes
\ingroup modules
\brief The Qt Xlsx module provides functionality for handling .xlsx files.
.xlsx is a zipped, XML-based file format developed by Microsoft for
representing spreadsheets.
*/
+83
View File
@@ -0,0 +1,83 @@
/*!
\page building
\title Qt Xlsx Build
\note QZipWriter and QZipReader which live in gui-private is used in
this library. 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* ;
if you Qt is built from source by yourself,
or download from qt-project.org directly, nothing need to do.
\section1 Usage(1): Use Xlsx as Qt5's addon module
1. Download the source code from \l {https://github.com/dbzhang800/QtXlsxWriter/archive/master.zip} {github.com}.
2. Put the source code in any directory you like. At the toplevel directory run
\note Perl is needed in this step.
\code
qmake
make
make install
\endcode
The library, the header files, and others will be installed to your system.
3. Add following line to your qmake's project file:
\code
QT += xlsx
\endcode
4. Then, using Qt Xlsx in your code
\code
#include "xlsxdocument.h"
int main()
{
QXlsx::Document xlsx;
xlsx.write("A1", "Hello Qt!");
xlsx.saveAs("Test.xlsx");
return 0;
}
\endcode
\section1 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.
1. Download the source code from \l {https://github.com/dbzhang800/QtXlsxWriter/archive/master.zip} {github.com}
2. Put the source code in any directory you like. For example, 3rdparty:
\code
|-- project.pro
|-- ....
|-- 3rdparty\
| |-- qtxlsx\
| |
\endcode
3. Add following line to your qmake project file:
\code
include(3rdparty/qtxlsx/src/xlsx/qtxlsx.pri)
\endcode
\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:
\code
include(qtxlsx.pri)
\endcode
\note If you do not use qmake, you need to define the following macro manually
\code
XLSX_NO_LIB
\endcode
4. Then, using Qt Xlsx in your code
*/
+16
View File
@@ -0,0 +1,16 @@
TARGET = QtXlsx
QMAKE_DOCS = $$PWD/doc/qtxlsx.qdocconf
load(qt_module)
CONFIG += build_xlsx_lib
include(qtxlsx.pri)
#Define this macro if you want to run tests, so more AIPs will get exported.
#DEFINES += XLSX_TEST
QMAKE_TARGET_COMPANY = "Debao Zhang"
QMAKE_TARGET_COPYRIGHT = "Copyright (C) 2013-2014 Debao Zhang <hello@debao.me>"
QMAKE_TARGET_DESCRIPTION = ".Xlsx file wirter for Qt5"
+7
View File
@@ -0,0 +1,7 @@
%modules = (
"QtXlsx" => "$basedir/src/xlsx",
);
%dependencies = (
"qtbase" => "",
);