├── .appveyor.yml ├── .gitignore ├── .qmake.conf ├── .travis.yml ├── CMakeLists.txt ├── COVER.md ├── QtXlsxWriterConfig.cmake.in ├── README.md ├── examples ├── examples.pro └── xlsx │ ├── CMakeLists.txt │ ├── calendar │ ├── calendar.pro │ └── main.cpp │ ├── chart │ ├── chart.pro │ └── main.cpp │ ├── chartsheet │ ├── chartsheet.pro │ └── main.cpp │ ├── conditionalformatting │ ├── conditionalformatting.pro │ ├── doc │ │ └── src │ │ │ └── conditionalformatting.qdoc │ └── main.cpp │ ├── datavalidation │ ├── datavalidation.pro │ └── main.cpp │ ├── definename │ ├── definename.pro │ └── main.cpp │ ├── demo │ ├── demo.pro │ ├── doc │ │ ├── images │ │ │ └── xlsx_demo.gif │ │ └── src │ │ │ └── demo.qdoc │ └── main.cpp │ ├── documentproperty │ ├── doc │ │ ├── images │ │ │ └── doc_property.png │ │ └── src │ │ │ └── documentproperty.qdoc │ ├── documentproperty.pro │ └── main.cpp │ ├── extractdata │ ├── doc │ │ └── src │ │ │ └── extractdata.qdoc │ ├── extractdata.pro │ └── main.cpp │ ├── formulas │ ├── doc │ │ └── src │ │ │ └── formulas.qdoc │ ├── formulas.pro │ └── main.cpp │ ├── hello │ ├── doc │ │ ├── images │ │ │ └── hello.png │ │ └── src │ │ │ └── hello.qdoc │ ├── hello.pro │ └── main.cpp │ ├── hyperlinks │ ├── hyperlinks.pro │ └── main.cpp │ ├── image │ ├── image.pro │ └── main.cpp │ ├── mergecells │ ├── doc │ │ ├── images │ │ │ └── xlsx-mergecells.png │ │ └── src │ │ │ └── mergecells.qdoc │ ├── main.cpp │ └── mergecells.pro │ ├── numberformat │ ├── main.cpp │ └── numberformat.pro │ ├── richtext │ ├── doc │ │ ├── images │ │ │ └── richtext.png │ │ └── src │ │ │ └── richtext.qdoc │ ├── main.cpp │ └── richtext.pro │ ├── rowcolumn │ ├── main.cpp │ └── rowcolumn.pro │ ├── style │ ├── doc │ │ └── src │ │ │ └── style.qdoc │ ├── main.cpp │ └── style.pro │ ├── worksheetoperations │ ├── doc │ │ └── src │ │ │ └── worksheetoperations.qdoc │ ├── main.cpp │ └── worksheetoperations.pro │ ├── xlsx.pro │ └── xlsxwidget │ ├── main.cpp │ ├── xlsxsheetmodel.cpp │ ├── xlsxsheetmodel.h │ ├── xlsxsheetmodel_p.h │ └── xlsxwidget.pro ├── qtxlsx.pro ├── src ├── src.pro └── xlsx │ ├── doc │ ├── qtxlsx.qdocconf │ ├── snippets │ │ ├── doc_src_qtxlsx.cpp │ │ └── doc_src_qtxlsx.pro │ └── src │ │ ├── examples.qdoc │ │ ├── qtxlsx-index.qdoc │ │ ├── qtxlsx.qdoc │ │ └── usage.qdoc │ ├── qtxlsx.pri │ ├── xlsx.pro │ ├── xlsxabstractooxmlfile.cpp │ ├── xlsxabstractooxmlfile.h │ ├── xlsxabstractooxmlfile_p.h │ ├── xlsxabstractsheet.cpp │ ├── xlsxabstractsheet.h │ ├── xlsxabstractsheet_p.h │ ├── xlsxcell.cpp │ ├── xlsxcell.h │ ├── xlsxcell_p.h │ ├── xlsxcellformula.cpp │ ├── xlsxcellformula.h │ ├── xlsxcellformula_p.h │ ├── xlsxcellrange.cpp │ ├── xlsxcellrange.h │ ├── xlsxcellreference.cpp │ ├── xlsxcellreference.h │ ├── xlsxchart.cpp │ ├── xlsxchart.h │ ├── xlsxchart_p.h │ ├── xlsxchartsheet.cpp │ ├── xlsxchartsheet.h │ ├── xlsxchartsheet_p.h │ ├── xlsxcolor.cpp │ ├── xlsxcolor_p.h │ ├── xlsxconditionalformatting.cpp │ ├── xlsxconditionalformatting.h │ ├── xlsxconditionalformatting_p.h │ ├── xlsxcontenttypes.cpp │ ├── xlsxcontenttypes_p.h │ ├── xlsxdatavalidation.cpp │ ├── xlsxdatavalidation.h │ ├── xlsxdatavalidation_p.h │ ├── xlsxdocpropsapp.cpp │ ├── xlsxdocpropsapp_p.h │ ├── xlsxdocpropscore.cpp │ ├── xlsxdocpropscore_p.h │ ├── xlsxdocument.cpp │ ├── xlsxdocument.h │ ├── xlsxdocument_p.h │ ├── xlsxdrawing.cpp │ ├── xlsxdrawing_p.h │ ├── xlsxdrawinganchor.cpp │ ├── xlsxdrawinganchor_p.h │ ├── xlsxformat.cpp │ ├── xlsxformat.h │ ├── xlsxformat_p.h │ ├── xlsxglobal.h │ ├── xlsxmediafile.cpp │ ├── xlsxmediafile_p.h │ ├── xlsxnumformatparser.cpp │ ├── xlsxnumformatparser_p.h │ ├── xlsxrelationships.cpp │ ├── xlsxrelationships_p.h │ ├── xlsxrichstring.cpp │ ├── xlsxrichstring.h │ ├── xlsxrichstring_p.h │ ├── xlsxsharedstrings.cpp │ ├── xlsxsharedstrings_p.h │ ├── xlsxsimpleooxmlfile.cpp │ ├── xlsxsimpleooxmlfile_p.h │ ├── xlsxstyles.cpp │ ├── xlsxstyles_p.h │ ├── xlsxtheme.cpp │ ├── xlsxtheme_p.h │ ├── xlsxutility.cpp │ ├── xlsxutility_p.h │ ├── xlsxworkbook.cpp │ ├── xlsxworkbook.h │ ├── xlsxworkbook_p.h │ ├── xlsxworksheet.cpp │ ├── xlsxworksheet.h │ ├── xlsxworksheet_p.h │ ├── xlsxzipreader.cpp │ ├── xlsxzipreader_p.h │ ├── xlsxzipwriter.cpp │ └── xlsxzipwriter_p.h ├── sync.profile └── tests ├── CMakeLists.txt ├── auto ├── CMakeLists.txt ├── auto.pro ├── cellreference │ ├── cellreference.pro │ └── tst_cellreferencetest.cpp ├── cmake │ ├── CMakeLists.txt │ └── cmake.pro ├── document │ ├── document.pro │ └── tst_documenttest.cpp ├── format │ ├── format.pro │ └── tst_formattest.cpp ├── propsapp │ ├── propsapp.pro │ └── tst_docpropsapptest.cpp ├── propscore │ ├── propscore.pro │ └── tst_propscoretest.cpp ├── relationships │ ├── relationships.pro │ └── tst_relationshipstest.cpp ├── richstring │ ├── richstring.pro │ └── tst_richstringtest.cpp ├── sharedstrings │ ├── sharedstrings.pro │ └── tst_sharedstringstest.cpp ├── styles │ ├── styles.pro │ └── tst_stylestest.cpp ├── utility │ ├── tst_utilitytest.cpp │ └── utility.pro ├── worksheet │ ├── tst_worksheet.cpp │ └── worksheet.pro ├── xlsxconditionalformatting │ ├── tst_conditionalformattingtest.cpp │ └── xlsxconditionalformatting.pro └── zipreader │ ├── tst_zipreadertest.cpp │ └── zipreader.pro ├── benchmarks ├── benchmarks.pro └── xmlspace │ ├── tst_xmlspacetest.cpp │ └── xmlspace.pro └── tests.pro /.appveyor.yml: -------------------------------------------------------------------------------- 1 | version: '0.3.0.{build}' 2 | 3 | image: Visual Studio 2015 4 | clone_depth: 1 5 | environment: 6 | global: 7 | # Appveyor doesn't have Qt 12 yet 8 | LatestLTSQtVersion: 5.9 9 | matrix: 10 | - QT5: C:\Qt\%LatestLTSQtVersion%\mingw53_32 11 | COMPILER: C:\Qt\Tools\mingw530_32 12 | targetPlatform: x86 13 | use_mingw: "true" 14 | use_cmake: "false" 15 | - QT5: C:\Qt\%LatestLTSQtVersion%\msvc2015_64 16 | COMPILER: C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC 17 | targetPlatform: amd64 18 | use_mingw: "false" 19 | use_cmake: "false" 20 | 21 | matrix: 22 | fast_finish: true 23 | 24 | before_build: 25 | - set PATH=%COMPILER%\bin;%QT5%\bin;%PATH% 26 | - set originalWD=%CD% 27 | - call "%QT5%\bin\qtenv2.bat" 28 | - cd %originalWD% 29 | - if %use_mingw%==false call "%COMPILER%\vcvarsall.bat" %targetPlatform% 30 | - if %use_mingw%==true (set MAKEENGINE=mingw32-make) else (set MAKEENGINE=nmake) 31 | - if %use_mingw%==true set PATH=%PATH:C:\Program Files\Git\usr\bin;=% 32 | 33 | build_script: 34 | - qmake "DEFINES += XLSX_TEST" 35 | - '%MAKEENGINE%' 36 | - '%MAKEENGINE% install' 37 | - cd tests 38 | - qmake 39 | - '%MAKEENGINE%' 40 | - '%MAKEENGINE% check TESTARGS="-o testResults.xml,xml"' 41 | 42 | after_build: 43 | - if %use_mingw%==true set PATH=C:\Program Files\Git\usr\bin;%PATH% 44 | 45 | on_finish: 46 | - ps: if (Test-Path ".\tests\testResults.xml") {(new-object net.webclient).UploadFile("https://ci.appveyor.com/api/testresults/junit/$($env:APPVEYOR_JOB_ID)", (Resolve-Path .\tests\testResults.xml));} 47 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | syntax: glob 2 | *.pro.user* 3 | *.autosave 4 | *.app 5 | *.moc 6 | *.prl 7 | Makefile* 8 | doc/html/ 9 | *.framework/ 10 | *.xcodeproj/ 11 | debug/ 12 | release/ 13 | qtc-gdbmacros/ 14 | *.rej 15 | *.orig 16 | *.obj 17 | *.swp 18 | *.dll 19 | *.exp 20 | *.ilk 21 | *.pdb 22 | *.lib 23 | Thumbs.db 24 | moc_*.cpp 25 | qrc_*.cpp 26 | *.o 27 | *.so.* 28 | *.so 29 | *.pdb 30 | ui_*.h 31 | *~ 32 | .qmake.cache 33 | lib/* 34 | *.orig 35 | *.exe 36 | *.vcproj 37 | *.vcproj.*.user 38 | *_resource.rc 39 | *.sln 40 | *.idb 41 | *.ncb 42 | *.suo 43 | 44 | *.zip 45 | *.xlsx 46 | -------------------------------------------------------------------------------- /.qmake.conf: -------------------------------------------------------------------------------- 1 | #Workaround for Issue #60 2 | CONFIG += git_build 3 | 4 | load(qt_build_config) 5 | 6 | MODULE_VERSION = 0.3.0 7 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: cpp 2 | 3 | git: 4 | depth: 1 5 | 6 | matrix: 7 | fast_finish: true 8 | include: 9 | - name: Ubuntu qmake test 10 | os: linux 11 | dist: xenial 12 | group: stable 13 | compiler: gcc 14 | addons: 15 | apt: 16 | sources: 17 | - ubuntu-toolchain-r-test 18 | - sourceline: 'ppa:beineri/opt-qt-5.12.0-xenial' 19 | update: true 20 | packages: 21 | - qt512base 22 | - qt512tools 23 | - gcc-6 24 | - g++-6 25 | - libc6-i386 26 | - libgl-dev 27 | - libgl1-mesa-dev 28 | - mesa-common-dev 29 | script: 30 | - PATH="/opt/qt512/bin:$PATH" 31 | - CXX="g++-6" 32 | - CC="gcc-6" 33 | - qt512-env.sh 34 | - qmake "DEFINES += XLSX_TEST" 35 | - make 36 | - sudo make install 37 | - cd tests 38 | - qmake 39 | - make 40 | - make check 41 | - name: Ubuntu qmake release 42 | os: linux 43 | dist: xenial 44 | group: stable 45 | compiler: gcc 46 | addons: 47 | apt: 48 | sources: 49 | - ubuntu-toolchain-r-test 50 | - sourceline: 'ppa:beineri/opt-qt-5.12.0-xenial' 51 | update: true 52 | packages: 53 | - qt512base 54 | - qt512tools 55 | - gcc-6 56 | - g++-6 57 | - libc6-i386 58 | - libgl-dev 59 | - libgl1-mesa-dev 60 | - mesa-common-dev 61 | script: 62 | - PATH="/opt/qt512/bin:$PATH" 63 | - CXX="g++-6" 64 | - CC="gcc-6" 65 | - qt512-env.sh 66 | - qmake 67 | - make 68 | - sudo make install 69 | - name: macOS qmake test 70 | os: osx 71 | osx_image: xcode10.1 72 | compiler: clang 73 | addons: 74 | homebrew: 75 | packages: 76 | - qt 77 | update: true 78 | script: 79 | - PATH="/usr/local/opt/qt5/bin:$PATH" 80 | - qmake "DEFINES += XLSX_TEST" 81 | - make 82 | - make install 83 | - cd tests 84 | - qmake 85 | - make 86 | - make check 87 | - name: macOS qmake release 88 | os: osx 89 | osx_image: xcode10.1 90 | compiler: clang 91 | addons: 92 | homebrew: 93 | packages: 94 | - qt 95 | update: true 96 | script: 97 | - PATH="/usr/local/opt/qt5/bin:$PATH" 98 | - qmake 99 | - make 100 | - make install 101 | 102 | notifications: 103 | email: false 104 | 105 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.2) 2 | 3 | project(QtXlsxWriter) 4 | add_definitions(-DQT_BUILD_XLSX_LIB) 5 | set(BUILD_SHARED_LIBS TRUE) 6 | set(CMAKE_AUTOMOC ON) 7 | 8 | if (NOT CMAKE_BUILD_TYPE) 9 | set(CMAKE_BUILD_TYPE "Release") 10 | endif() 11 | 12 | file( 13 | GLOB 14 | QtXlsxWriter_SOURCE_FILES 15 | ${CMAKE_CURRENT_SOURCE_DIR}/src/xlsx/*.cpp 16 | ${CMAKE_CURRENT_BINARY_DIR}/QtXlsxWriterTest_automoc.cpp 17 | ) 18 | 19 | find_package(Qt5 5.5 REQUIRED Core Gui Test) 20 | include_directories( 21 | ${CMAKE_CURRENT_SOURCE_DIR}/src/xlsx/ 22 | ${Qt5Core_INCLUDE_DIRS} 23 | ${Qt5Gui_INCLUDE_DIRS} 24 | ${Qt5Gui_PRIVATE_INCLUDE_DIRS} ) 25 | 26 | add_library(QtXlsxWriter SHARED "${QtXlsxWriter_SOURCE_FILES}") 27 | 28 | # automatically add C++11 support with GCC 29 | if(NOT MSVC) 30 | target_compile_features(QtXlsxWriter PRIVATE cxx_range_for) 31 | endif() 32 | 33 | set_target_properties(QtXlsxWriter PROPERTIES DEBUG_POSTFIX "d") 34 | target_link_libraries(QtXlsxWriter ${Qt5Core_LIBRARIES}) 35 | target_link_libraries(QtXlsxWriter ${Qt5Gui_LIBRARIES}) 36 | 37 | target_include_directories(QtXlsxWriter 38 | INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/src/xlsx 39 | ) 40 | 41 | if(BUILD_TESTING) 42 | add_subdirectory(tests) 43 | endif() 44 | 45 | if(BUILD_EXAMPLES) 46 | add_custom_command(TARGET QtXlsxWriter POST_BUILD 47 | COMMAND ${CMAKE_COMMAND} 48 | -E copy_directory $ ${CMAKE_CURRENT_BINARY_DIR}/examples/xlsx/$) 49 | add_subdirectory(examples/xlsx) 50 | endif() 51 | 52 | ## 53 | # 54 | # QtxlsxwriterVersion.cmake creation 55 | # 56 | ## 57 | set(QtXlsxWriter_CONFIG_PATH ${CMAKE_INSTALL_PREFIX}) 58 | configure_file(QtXlsxWriterConfig.cmake.in QtXlsxWriterConfig.cmake @ONLY) 59 | 60 | ##### 61 | # 62 | # Installation configuration 63 | # 64 | ##### 65 | INSTALL(TARGETS QtXlsxWriter 66 | RUNTIME DESTINATION bin 67 | LIBRARY DESTINATION lib 68 | ARCHIVE DESTINATION lib 69 | ) 70 | 71 | INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/QtXlsxWriterConfig.cmake DESTINATION lib/cmake/${PROJECT_NAME}) 72 | 73 | SET(INCLUDE_FILES 74 | src/xlsx/xlsxabstractooxmlfile.h 75 | src/xlsx/xlsxabstractsheet.h 76 | src/xlsx/xlsxcell.h 77 | src/xlsx/xlsxcellformula.h 78 | src/xlsx/xlsxcellrange.h 79 | src/xlsx/xlsxcellreference.h 80 | src/xlsx/xlsxchart.h 81 | src/xlsx/xlsxchartsheet.h 82 | src/xlsx/xlsxconditionalformatting.h 83 | src/xlsx/xlsxdatavalidation.h 84 | src/xlsx/xlsxdocument.h 85 | src/xlsx/xlsxformat.h 86 | src/xlsx/xlsxglobal.h 87 | src/xlsx/xlsxrichstring.h 88 | src/xlsx/xlsxworkbook.h 89 | src/xlsx/xlsxworksheet.h 90 | ) 91 | INSTALL(FILES ${INCLUDE_FILES} DESTINATION include) 92 | 93 | -------------------------------------------------------------------------------- /COVER.md: -------------------------------------------------------------------------------- 1 | Documentation: http://qtxlsx.debao.me 2 | 3 | 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. 4 | The library can be used to 5 | 6 | * Generate a new .xlsx file from scratch 7 | * Extract data from an existing .xlsx file 8 | * Edit an existing .xlsx file 9 | 10 | ## Getting Started 11 | 12 | > * 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* 13 | 14 | ### Usage(1): Use Xlsx as Qt5's addon module 15 | 16 | #### Building the module 17 | 18 | > **Note**: Perl is needed in this step. 19 | 20 | * Download the source code. 21 | 22 | * Put the source code in any directory you like 23 | 24 | * Go to top directory of the project in a terminal and run 25 | 26 | ``` 27 | qmake 28 | make 29 | make install 30 | ``` 31 | 32 | The library, the header files, and others will be installed to your system. 33 | 34 | > ```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. 35 | 36 | #### Using the module 37 | 38 | * Add following line to your qmake's project file: 39 | 40 | ``` 41 | QT += xlsx 42 | ``` 43 | 44 | * Then, using Qt Xlsx in your code 45 | 46 | ```cpp 47 | #include 48 | int main() 49 | { 50 | QXlsx::Document xlsx; 51 | xlsx.write("A1", "Hello Qt!"); 52 | xlsx.saveAs("Test.xlsx"); 53 | return 0; 54 | } 55 | ``` 56 | 57 | ### Usage(2): Use source code directly 58 | 59 | The package contains a **qtxlsx.pri** file that allows you to integrate the component into applications that use qmake for the build step. 60 | 61 | * Download the source code. 62 | 63 | * Put the source code in any directory you like. For example, 3rdparty: 64 | 65 | ``` 66 | |-- project.pro 67 | |-- .... 68 | |-- 3rdparty\ 69 | | |-- qtxlsx\ 70 | | | 71 | ``` 72 | 73 | * Add following line to your qmake project file: 74 | 75 | ``` 76 | include(3rdparty/qtxlsx/src/xlsx/qtxlsx.pri) 77 | ``` 78 | 79 | > **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: 80 | 81 | > ``` 82 | include(qtxlsx.pri) 83 | ``` 84 | 85 | > **Note**: If you do not use qmake, you need to define the following macro manually 86 | 87 | > ``` 88 | XLSX_NO_LIB 89 | ``` 90 | 91 | 92 | * Then, using Qt Xlsx in your code 93 | 94 | ```cpp 95 | #include "xlsxdocument.h" 96 | int main() 97 | { 98 | QXlsx::Document xlsx; 99 | xlsx.write("A1", "Hello Qt!"); 100 | xlsx.saveAs("Test.xlsx"); 101 | return 0; 102 | } 103 | ``` 104 | 105 | ## References 106 | 107 | * http://www.ecma-international.org/publications/standards/Ecma-376.htm 108 | * http://www.iso.org/iso/catalogue_detail?csnumber=51463 109 | * http://msdn.microsoft.com/en-us/library/ee908652%28v=office.12%29.aspx 110 | * http://www.datypic.com/sc/ooxml/ 111 | 112 | ### General 113 | 114 | * https://github.com/jmcnamara/XlsxWriter 115 | * http://openpyxl.readthedocs.org 116 | * http://officeopenxml.com/anatomyofOOXML-xlsx.php 117 | * http://www.libxl.com 118 | * http://closedxml.codeplex.com/ 119 | * http://epplus.codeplex.com/ 120 | * http://excelpackage.codeplex.com/ 121 | * http://spreadsheetlight.com/ 122 | 123 | ### Number formats 124 | 125 | * http://msdn.microsoft.com/en-us/library/ff529356%28v=office.12%29.aspx 126 | * http://www.ozgrid.com/Excel/excel-custom-number-formats.htm 127 | * http://stackoverflow.com/questions/894805/excel-number-format-what-is-409 128 | * http://office.microsoft.com/en-001/excel-help/create-a-custom-number-format-HP010342372.aspx 129 | 130 | ### Formula 131 | 132 | * http://msdn.microsoft.com/en-us/library/ff533995%28v=office.12%29.aspx 133 | * http://msdn.microsoft.com/en-us/library/dd906358%28v=office.12%29.aspx 134 | * http://homepages.ecs.vuw.ac.nz/~elvis/db/Excel.shtml 135 | * http://ewbi.blogs.com/develops/2004/12/excel_formula_p.html 136 | -------------------------------------------------------------------------------- /QtXlsxWriterConfig.cmake.in: -------------------------------------------------------------------------------- 1 | ######################################### 2 | # 3 | # Cmake QtXlsxWriter configuration file 4 | # 5 | # Usage from an external project: 6 | # In your CMakeLists.txt, add these lines: 7 | # 8 | # FIND_PACKAGE(QtXlsxWriter REQUIRED) 9 | # TARGET_LINK_LIBRARIES(MY_TARGET_NAME ${QtXlsxWriter_LIBS}) 10 | # 11 | # This file will define the following variables: 12 | # 13 | # - QtXlsxWriter_BIN : The list of libraries to link against (.DLL, .SO). 14 | # - QtXlsxWriter_LIBS : The list of libraries to link against (LIB, .A). 15 | # - QtXlsxWriter_LIB_DIR : The directory(es) where lib files are. Calling LINK_DIRECTORIES 16 | # with this path is NOT needed. 17 | # - QtXlsxWriter_INCLUDE_DIRS : The QtXlsxWriter include directories (automatically added) 18 | # 19 | ######################################### 20 | 21 | if(CMAKE_VERSION VERSION_GREATER 2.6.2) 22 | unset(QtXlsxWriter_CONFIG_PATH CACHE) 23 | endif() 24 | 25 | set(QtXlsxWriter_CONFIG_PATH "@QtXlsxWriter_CONFIG_PATH@") 26 | set(QtXlsxWriter_FOUND TRUE CACHE BOOL "" FORCE) 27 | set(QtXlsxWriter_LIBS QtXlsxWriter) 28 | set(QtXlsxWriter_LIB_BIN ${QtXlsxWriter_CONFIG_PATH}/bin) 29 | set(QtXlsxWriter_LIB_DIR ${QtXlsxWriter_CONFIG_PATH}/lib) 30 | set(QtXlsxWriter_INCLUDE_DIRS ${QtXlsxWriter_CONFIG_PATH}/include) 31 | 32 | include_directories(BEFORE ${QtXlsxWriter_INCLUDE_DIRS}) 33 | 34 | link_directories( ${LINK_DIRECTORIES} ${QtXlsxWriter_LIB_DIR} ) 35 | 36 | include(FindPackageHandleStandardArgs) 37 | find_package_handle_standard_args( QtXlsxWriter DEFAULT_MSG 38 | QtXlsxWriter_LIBS QtXlsxWriter_INCLUDE_DIRS) 39 | 40 | mark_as_advanced(FORCE QtXlsxWriter_LIBS QtXlsxWriter_LIB_DIR QtXlsxWriter_INCLUDE_DIRS) 41 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # This repository is unmaintained. 2 | 3 | The suggested alternative is [QXlsx](https://github.com/QtExcel/QXlsx) or refer to [the Qt wiki](https://wiki.qt.io/Handling_Microsoft_Excel_file_format) 4 | 5 | [Original Readme](COVER.md) 6 | -------------------------------------------------------------------------------- /examples/examples.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = xlsx 3 | 4 | -------------------------------------------------------------------------------- /examples/xlsx/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(Qt5 5.5 REQUIRED Core Gui Test Widgets) 2 | 3 | set(EXAMPLES 4 | calendar 5 | chart 6 | chartsheet 7 | conditionalformatting 8 | datavalidation 9 | definename 10 | demo 11 | documentproperty 12 | extractdata 13 | formulas 14 | hello 15 | hyperlinks 16 | image 17 | mergecells 18 | numberformat 19 | richtext 20 | rowcolumn 21 | style 22 | worksheetoperations 23 | xlsxwidget) 24 | 25 | # Compile each defined example 26 | foreach(example IN ITEMS ${EXAMPLES}) 27 | if(DEBUG) 28 | message("Create example '${example}'") 29 | endif() 30 | file( GLOB TEST_SRC ${example}/*.cpp) 31 | include_directories( 32 | ${CMAKE_CURRENT_SOURCE_DIR}/../../src/xlsx/ 33 | ${Qt5Core_INCLUDE_DIRS} 34 | ${Qt5Gui_INCLUDE_DIRS} 35 | ${Qt5Widgets_INCLUDE_DIRS} 36 | ${QtXlsxWriter_PRIVATE_SOURCE_FILES} 37 | ${CMAKE_CURRENT_BINARY_DIR} # .moc files 38 | ) 39 | 40 | remove_definitions(-DQT_BUILD_XLSX_LIB) 41 | 42 | add_executable(${example} ${TEST_SRC} ) 43 | 44 | target_link_libraries(${example} ${Qt5Widgets_LIBRARIES}) 45 | target_link_libraries(${example} ${Qt5Core_LIBRARIES}) 46 | target_link_libraries(${example} ${Qt5Gui_LIBRARIES}) 47 | target_link_libraries(${example} ${Qt5Test_LIBRARIES}) 48 | target_link_libraries(${example} QtXlsxWriter) 49 | 50 | endforeach(example) 51 | -------------------------------------------------------------------------------- /examples/xlsx/calendar/calendar.pro: -------------------------------------------------------------------------------- 1 | TARGET = calendar 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT+=xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | -------------------------------------------------------------------------------- /examples/xlsx/chart/chart.pro: -------------------------------------------------------------------------------- 1 | TARGET = chart 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT+=xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | -------------------------------------------------------------------------------- /examples/xlsx/chart/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xlsxdocument.h" 3 | #include "xlsxcellrange.h" 4 | #include "xlsxchart.h" 5 | 6 | using namespace QXlsx; 7 | 8 | int main() 9 | { 10 | //![0] 11 | Document xlsx; 12 | for (int i=1; i<10; ++i) { 13 | xlsx.write(i, 1, i*i*i); //A1:A9 14 | xlsx.write(i, 2, i*i); //B1:B9 15 | xlsx.write(i, 3, i*i-1); //C1:C9 16 | } 17 | //![0] 18 | 19 | //![1] 20 | Chart *pieChart = xlsx.insertChart(3, 3, QSize(300, 300)); 21 | pieChart->setChartType(Chart::CT_Pie); 22 | pieChart->addSeries(CellRange("A1:A9")); 23 | pieChart->addSeries(CellRange("B1:B9")); 24 | pieChart->addSeries(CellRange("C1:C9")); 25 | 26 | Chart *pie3DChart = xlsx.insertChart(3, 9, QSize(300, 300)); 27 | pie3DChart->setChartType(Chart::CT_Pie3D); 28 | pie3DChart->addSeries(CellRange("A1:C9")); 29 | 30 | Chart *barChart = xlsx.insertChart(23, 3, QSize(300, 300)); 31 | barChart->setChartType(Chart::CT_Bar); 32 | barChart->addSeries(CellRange("A1:C9")); 33 | 34 | Chart *bar3DChart = xlsx.insertChart(23, 9, QSize(300, 300)); 35 | bar3DChart->setChartType(Chart::CT_Bar3D); 36 | bar3DChart->addSeries(CellRange("A1:C9")); 37 | 38 | Chart *lineChart = xlsx.insertChart(43, 3, QSize(300, 300)); 39 | lineChart->setChartType(Chart::CT_Line); 40 | lineChart->addSeries(CellRange("A1:C9")); 41 | 42 | Chart *line3DChart = xlsx.insertChart(43, 9, QSize(300, 300)); 43 | line3DChart->setChartType(Chart::CT_Line3D); 44 | line3DChart->addSeries(CellRange("A1:C9")); 45 | 46 | Chart *areaChart = xlsx.insertChart(63, 3, QSize(300, 300)); 47 | areaChart->setChartType(Chart::CT_Area); 48 | areaChart->addSeries(CellRange("A1:C9")); 49 | 50 | Chart *area3DChart = xlsx.insertChart(63, 9, QSize(300, 300)); 51 | area3DChart->setChartType(Chart::CT_Area3D); 52 | area3DChart->addSeries(CellRange("A1:C9")); 53 | 54 | Chart *scatterChart = xlsx.insertChart(83, 3, QSize(300, 300)); 55 | scatterChart->setChartType(Chart::CT_Scatter); 56 | //Will generate three lines. 57 | scatterChart->addSeries(CellRange("A1:A9")); 58 | scatterChart->addSeries(CellRange("B1:B9")); 59 | scatterChart->addSeries(CellRange("C1:C9")); 60 | 61 | Chart *scatterChart_2 = xlsx.insertChart(83, 9, QSize(300, 300)); 62 | scatterChart_2->setChartType(Chart::CT_Scatter); 63 | //Will generate two lines. 64 | scatterChart_2->addSeries(CellRange("A1:C9")); 65 | 66 | Chart *doughnutChart = xlsx.insertChart(103, 3, QSize(300, 300)); 67 | doughnutChart->setChartType(Chart::CT_Doughnut); 68 | doughnutChart->addSeries(CellRange("A1:C9")); 69 | //![1] 70 | 71 | //![2] 72 | xlsx.saveAs("Book1.xlsx"); 73 | //![2] 74 | 75 | Document xlsx2("Book1.xlsx"); 76 | xlsx2.saveAs("Book2.xlsx"); 77 | return 0; 78 | } 79 | -------------------------------------------------------------------------------- /examples/xlsx/chartsheet/chartsheet.pro: -------------------------------------------------------------------------------- 1 | TARGET = chartsheet 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT+=xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | -------------------------------------------------------------------------------- /examples/xlsx/chartsheet/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xlsxdocument.h" 3 | #include "xlsxchartsheet.h" 4 | #include "xlsxcellrange.h" 5 | #include "xlsxchart.h" 6 | 7 | using namespace QXlsx; 8 | 9 | int main() 10 | { 11 | //![0] 12 | Document xlsx; 13 | for (int i=1; i<10; ++i) 14 | xlsx.write(i, 1, i*i); 15 | //![0] 16 | 17 | //![1] 18 | xlsx.addSheet("Chart1", AbstractSheet::ST_ChartSheet); 19 | Chartsheet *sheet = static_cast(xlsx.currentSheet()); 20 | Chart *barChart = sheet->chart(); 21 | barChart->setChartType(Chart::CT_Bar); 22 | barChart->addSeries(CellRange("A1:A9"), xlsx.sheet("Sheet1")); 23 | //![1] 24 | 25 | //![2] 26 | xlsx.saveAs("Book1.xlsx"); 27 | //![2] 28 | 29 | Document xlsx2("Book1.xlsx"); 30 | xlsx2.saveAs("Book2.xlsx"); 31 | return 0; 32 | } 33 | -------------------------------------------------------------------------------- /examples/xlsx/conditionalformatting/conditionalformatting.pro: -------------------------------------------------------------------------------- 1 | TARGET = hello 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT+=xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | -------------------------------------------------------------------------------- /examples/xlsx/conditionalformatting/doc/src/conditionalformatting.qdoc: -------------------------------------------------------------------------------- 1 | /*! 2 | \example conditionalformatting 3 | \title Conditional Formatting Example 4 | \brief This is a conditional formatting example. 5 | \ingroup qtxlsx-examples 6 | 7 | This example demonstrates how to create a new 8 | .xlsx file containin conditional formatting 9 | with Qt Xlsx Library. So lets see how this is achieved. 10 | */ 11 | -------------------------------------------------------------------------------- /examples/xlsx/conditionalformatting/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xlsxdocument.h" 3 | #include "xlsxconditionalformatting.h" 4 | 5 | using namespace QXlsx; 6 | 7 | int main() 8 | { 9 | //![0] 10 | Document xlsx; 11 | Format hFmt; 12 | hFmt.setFontBold(true); 13 | xlsx.write("B1", "(-inf,40)", hFmt); 14 | xlsx.write("C1", "[30,70]", hFmt); 15 | xlsx.write("D1", "startsWith 2", hFmt); 16 | xlsx.write("E1", "dataBar", hFmt); 17 | xlsx.write("F1", "colorScale", hFmt); 18 | 19 | for (int row=3; row<22; ++row) { 20 | for (int col=2; col<22; ++col) 21 | xlsx.write(row, col, qrand() % 100); 22 | } 23 | //![0] 24 | 25 | //![cf1] 26 | ConditionalFormatting cf1; 27 | Format fmt1; 28 | fmt1.setFontColor(Qt::green); 29 | fmt1.setBorderStyle(Format::BorderDashed); 30 | cf1.addHighlightCellsRule(ConditionalFormatting::Highlight_LessThan, "40", fmt1); 31 | cf1.addRange("B3:B21"); 32 | xlsx.addConditionalFormatting(cf1); 33 | //![cf1] 34 | 35 | //![cf2] 36 | ConditionalFormatting cf2; 37 | Format fmt2; 38 | fmt2.setBorderStyle(Format::BorderDotted); 39 | fmt2.setBorderColor(Qt::blue); 40 | cf2.addHighlightCellsRule(ConditionalFormatting::Highlight_Between, "30", "70", fmt2); 41 | cf2.addRange("C3:C21"); 42 | xlsx.addConditionalFormatting(cf2); 43 | //![cf2] 44 | 45 | //![cf3] 46 | ConditionalFormatting cf3; 47 | Format fmt3; 48 | fmt3.setFontStrikeOut(true); 49 | fmt3.setFontBold(true); 50 | cf3.addHighlightCellsRule(ConditionalFormatting::Highlight_BeginsWith, "2", fmt3); 51 | cf3.addRange("D3:D21"); 52 | xlsx.addConditionalFormatting(cf3); 53 | //![cf3] 54 | 55 | //![cf4] 56 | ConditionalFormatting cf4; 57 | cf4.addDataBarRule(Qt::blue); 58 | cf4.addRange("E3:E21"); 59 | xlsx.addConditionalFormatting(cf4); 60 | //![cf4] 61 | 62 | //![cf5] 63 | ConditionalFormatting cf5; 64 | cf5.add2ColorScaleRule(Qt::blue, Qt::red); 65 | cf5.addRange("F3:F21"); 66 | xlsx.addConditionalFormatting(cf5); 67 | //![cf5] 68 | 69 | //![2] 70 | xlsx.saveAs("Book1.xlsx"); 71 | //![2] 72 | 73 | Document xlsx2("Book1.xlsx"); 74 | xlsx2.saveAs("Book2.xlsx"); 75 | return 0; 76 | } 77 | -------------------------------------------------------------------------------- /examples/xlsx/datavalidation/datavalidation.pro: -------------------------------------------------------------------------------- 1 | TARGET = datavalidation 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT+=xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | -------------------------------------------------------------------------------- /examples/xlsx/datavalidation/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xlsxdocument.h" 3 | #include "xlsxdatavalidation.h" 4 | 5 | QTXLSX_USE_NAMESPACE 6 | 7 | int main() 8 | { 9 | Document xlsx; 10 | xlsx.write("A1", "A2 and A3:E5 only accept the number between 33 and 99"); 11 | 12 | //![1] 13 | DataValidation validation(DataValidation::Whole, DataValidation::Between, "33", "99"); 14 | validation.addRange("A2"); 15 | validation.addRange("A3:E5"); 16 | validation.setPromptMessage("Please Input Integer between 33 and 99"); 17 | xlsx.addDataValidation(validation); 18 | //![1] 19 | 20 | xlsx.save(); 21 | return 0; 22 | } 23 | -------------------------------------------------------------------------------- /examples/xlsx/definename/definename.pro: -------------------------------------------------------------------------------- 1 | TARGET = definename 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT+=xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | -------------------------------------------------------------------------------- /examples/xlsx/definename/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xlsxdocument.h" 3 | 4 | QTXLSX_USE_NAMESPACE 5 | 6 | int main() 7 | { 8 | //![0] 9 | Document xlsx; 10 | for (int i=1; i<=10; ++i) { 11 | xlsx.write(i, 1, i); 12 | xlsx.write(i, 2, i*i); 13 | xlsx.write(i, 3, i*i*i); 14 | } 15 | //![0] 16 | //![1] 17 | xlsx.defineName("MyCol_1", "=Sheet1!$A$1:$A$10"); 18 | xlsx.defineName("MyCol_2", "=Sheet1!$B$1:$B$10", "This is comments"); 19 | xlsx.defineName("MyCol_3", "=Sheet1!$C$1:$C$10", "", "Sheet1"); 20 | xlsx.defineName("Factor", "=0.5"); 21 | //![1] 22 | //![2] 23 | xlsx.write(11, 1, "=SUM(MyCol_1)"); 24 | xlsx.write(11, 2, "=SUM(MyCol_2)"); 25 | xlsx.write(11, 3, "=SUM(MyCol_3)"); 26 | xlsx.write(12, 1, "=SUM(MyCol_1)*Factor"); 27 | xlsx.write(12, 2, "=SUM(MyCol_2)*Factor"); 28 | xlsx.write(12, 3, "=SUM(MyCol_3)*Factor"); 29 | //![2] 30 | 31 | xlsx.save(); 32 | return 0; 33 | } 34 | -------------------------------------------------------------------------------- /examples/xlsx/demo/demo.pro: -------------------------------------------------------------------------------- 1 | TARGET = demo 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT+=xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | -------------------------------------------------------------------------------- /examples/xlsx/demo/doc/images/xlsx_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VSRonin/QtXlsxWriter/01eb671564b05bd11470046d0eaeef6d806bb9e6/examples/xlsx/demo/doc/images/xlsx_demo.gif -------------------------------------------------------------------------------- /examples/xlsx/demo/doc/src/demo.qdoc: -------------------------------------------------------------------------------- 1 | /*! 2 | \example demo 3 | \title Qt Xlsx Demo 4 | \brief This is a demo which is used to show features of the library 5 | \ingroup qtxlsx-examples 6 | 7 | \image xlsx_demo.gif 8 | */ 9 | -------------------------------------------------------------------------------- /examples/xlsx/documentproperty/doc/images/doc_property.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VSRonin/QtXlsxWriter/01eb671564b05bd11470046d0eaeef6d806bb9e6/examples/xlsx/documentproperty/doc/images/doc_property.png -------------------------------------------------------------------------------- /examples/xlsx/documentproperty/doc/src/documentproperty.qdoc: -------------------------------------------------------------------------------- 1 | /*! 2 | \example documentproperty 3 | \title Document Properties Example 4 | \brief This is a simplest xlsx examples. 5 | 6 | \image doc_property.png 7 | 8 | \ingroup qtxlsx-examples 9 | 10 | This example demonstrates how to set the document properties. 11 | */ 12 | -------------------------------------------------------------------------------- /examples/xlsx/documentproperty/documentproperty.pro: -------------------------------------------------------------------------------- 1 | TARGET = ducumentproperty 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT+=xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | 12 | -------------------------------------------------------------------------------- /examples/xlsx/documentproperty/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xlsxdocument.h" 3 | 4 | int main() 5 | { 6 | QXlsx::Document xlsx; 7 | xlsx.write("A1", "View the properties through:"); 8 | xlsx.write("A2", "Office Button -> Prepare -> Properties option in Excel"); 9 | 10 | xlsx.setDocumentProperty("title", "This is an example spreadsheet"); 11 | xlsx.setDocumentProperty("subject", "With document properties"); 12 | xlsx.setDocumentProperty("creator", "Debao Zhang"); 13 | xlsx.setDocumentProperty("company", "HMICN"); 14 | xlsx.setDocumentProperty("category", "Example spreadsheets"); 15 | xlsx.setDocumentProperty("keywords", "Sample, Example, Properties"); 16 | xlsx.setDocumentProperty("description", "Created with Qt Xlsx"); 17 | 18 | xlsx.saveAs("Test.xlsx"); 19 | return 0; 20 | } 21 | -------------------------------------------------------------------------------- /examples/xlsx/extractdata/doc/src/extractdata.qdoc: -------------------------------------------------------------------------------- 1 | /*! 2 | \example extractdata 3 | \title Extract Data Example 4 | \brief This is a simplest Qt Xlsx example. 5 | \ingroup qtxlsx-examples 6 | 7 | This example demonstrates how to extract data form existing 8 | .xlsx file with Qt Xlsx Library. So lets see how this is achieved. 9 | 10 | This creates a new instance of the all important Document 11 | class which gives you access to the Excel workbook and worksheets. 12 | \snippet extractdata/main.cpp 0 13 | 14 | Extracts data from current worksheet. 15 | \snippet extractdata/main.cpp 1 16 | */ 17 | -------------------------------------------------------------------------------- /examples/xlsx/extractdata/extractdata.pro: -------------------------------------------------------------------------------- 1 | TARGET = extractdata 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT+=xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | -------------------------------------------------------------------------------- /examples/xlsx/extractdata/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xlsxdocument.h" 3 | 4 | int main() 5 | { 6 | { 7 | //Create a new .xlsx file. 8 | QXlsx::Document xlsx; 9 | xlsx.write("A1", "Hello Qt!"); 10 | xlsx.write("A2", 12345); 11 | xlsx.write("A3", "=44+33"); 12 | xlsx.write("A4", true); 13 | xlsx.write("A5", "http://qt-project.org"); 14 | xlsx.write("A6", QDate(2013, 12, 27)); 15 | xlsx.write("A7", QTime(6, 30)); 16 | xlsx.saveAs("Book1.xlsx"); 17 | } 18 | 19 | //![0] 20 | QXlsx::Document xlsx("Book1.xlsx"); 21 | //![0] 22 | 23 | //![1] 24 | qDebug()<value(); 37 | } 38 | //![2] 39 | 40 | return 0; 41 | } 42 | -------------------------------------------------------------------------------- /examples/xlsx/formulas/doc/src/formulas.qdoc: -------------------------------------------------------------------------------- 1 | /*! 2 | \example formulas 3 | \title Formulas Example 4 | \brief This is a simplest Qt Xlsx example. 5 | \ingroup qtxlsx-examples 6 | 7 | This example demonstrates how to create a new 8 | .xlsx file containing formulas 9 | with Qt Xlsx Library. So lets see how this is achieved. 10 | 11 | This creates a new instance of the all important Document 12 | class which gives you access to the Excel workbook and worksheets. 13 | \snippet formulas/main.cpp 0 14 | 15 | A default worksheet have been created by Document. Let's start 16 | by adding some basic formulas. 17 | \snippet formulas/main.cpp 1 18 | 19 | Then add one array formula. 20 | \snippet formulas/main.cpp 2 21 | 22 | Now save the file and all its components. 23 | \snippet formulas/main.cpp 3 24 | */ 25 | -------------------------------------------------------------------------------- /examples/xlsx/formulas/formulas.pro: -------------------------------------------------------------------------------- 1 | TARGET = hello 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT+=xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | -------------------------------------------------------------------------------- /examples/xlsx/formulas/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xlsxdocument.h" 3 | #include "xlsxformat.h" 4 | #include "xlsxworksheet.h" 5 | #include "xlsxcellformula.h" 6 | 7 | QTXLSX_USE_NAMESPACE 8 | 9 | int main() 10 | { 11 | //![0] 12 | Document xlsx; 13 | //![0] 14 | 15 | //![1] 16 | xlsx.setColumnWidth(1, 2, 40); 17 | Format rAlign; 18 | rAlign.setHorizontalAlignment(Format::AlignRight); 19 | Format lAlign; 20 | lAlign.setHorizontalAlignment(Format::AlignLeft); 21 | xlsx.write("B3", 40, lAlign); 22 | xlsx.write("B4", 30, lAlign); 23 | xlsx.write("B5", 50, lAlign); 24 | xlsx.write("A7", "SUM(B3:B5)=", rAlign); 25 | xlsx.write("B7", "=SUM(B3:B5)", lAlign); 26 | xlsx.write("A8", "AVERAGE(B3:B5)=", rAlign); 27 | xlsx.write("B8", "=AVERAGE(B3:B5)", lAlign); 28 | xlsx.write("A9", "MAX(B3:B5)=", rAlign); 29 | xlsx.write("B9", "=MAX(B3:B5)", lAlign); 30 | xlsx.write("A10", "MIN(B3:B5)=", rAlign); 31 | xlsx.write("B10", "=MIN(B3:B5)", lAlign); 32 | xlsx.write("A11", "COUNT(B3:B5)=", rAlign); 33 | xlsx.write("B11", "=COUNT(B3:B5)", lAlign); 34 | 35 | xlsx.write("A13", "IF(B7>100,\"large\",\"small\")=", rAlign); 36 | xlsx.write("B13", "=IF(B7>100,\"large\",\"small\")", lAlign); 37 | 38 | xlsx.write("A15", "SQRT(25)=", rAlign); 39 | xlsx.write("B15", "=SQRT(25)", lAlign); 40 | xlsx.write("A16", "RAND()=", rAlign); 41 | xlsx.write("B16", "=RAND()", lAlign); 42 | xlsx.write("A17", "2*PI()=", rAlign); 43 | xlsx.write("B17", "=2*PI()", lAlign); 44 | 45 | xlsx.write("A19", "UPPER(\"qtxlsx\")=", rAlign); 46 | xlsx.write("B19", "=UPPER(\"qtxlsx\")", lAlign); 47 | xlsx.write("A20", "LEFT(\"ubuntu\",3)=", rAlign); 48 | xlsx.write("B20", "=LEFT(\"ubuntu\",3)", lAlign); 49 | xlsx.write("A21", "LEN(\"Hello Qt!\")=", rAlign); 50 | xlsx.write("B21", "=LEN(\"Hello Qt!\")", lAlign); 51 | //![1] 52 | 53 | //![2] 54 | xlsx.addSheet("ArrayFormula"); 55 | Worksheet *sheet = xlsx.currentWorksheet(); 56 | 57 | for (int row=2; row<20; ++row) { 58 | sheet->write(row, 2, row*2); //B2:B19 59 | sheet->write(row, 3, row*3); //C2:C19 60 | } 61 | sheet->writeFormula("D2", CellFormula("B2:B19+C2:C19", "D2:D19", CellFormula::ArrayType)); 62 | sheet->writeFormula("E2", CellFormula("=CONCATENATE(\"The total is \",D2:D19,\" units\")", "E2:E19", CellFormula::ArrayType)); 63 | //![2] 64 | 65 | //![21] 66 | xlsx.addSheet("SharedFormula"); 67 | sheet = xlsx.currentWorksheet(); 68 | 69 | for (int row=2; row<20; ++row) { 70 | sheet->write(row, 2, row*2); //B2:B19 71 | sheet->write(row, 3, row*3); //C2:C19 72 | } 73 | sheet->writeFormula("D2", CellFormula("=B2+C2", "D2:D19", CellFormula::SharedType)); 74 | sheet->writeFormula("E2", CellFormula("=CONCATENATE(\"The total is \",D2,\" units\")", "E2:E19", CellFormula::SharedType)); 75 | 76 | //![21] 77 | 78 | //![3] 79 | xlsx.save(); 80 | //![3] 81 | 82 | //Make sure that read/write works well. 83 | Document xlsx2("Book1.xlsx"); 84 | Worksheet *sharedFormulaSheet = dynamic_cast(xlsx2.sheet("SharedFormula")); 85 | for (int row=2; row<20; ++row) { 86 | qDebug()<read(row, 4); 87 | } 88 | 89 | xlsx2.saveAs("Book2.xlsx"); 90 | 91 | return 0; 92 | } 93 | -------------------------------------------------------------------------------- /examples/xlsx/hello/doc/images/hello.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VSRonin/QtXlsxWriter/01eb671564b05bd11470046d0eaeef6d806bb9e6/examples/xlsx/hello/doc/images/hello.png -------------------------------------------------------------------------------- /examples/xlsx/hello/doc/src/hello.qdoc: -------------------------------------------------------------------------------- 1 | /*! 2 | \example hello 3 | \title Hello QtXlsx Example 4 | \brief This is a simplest Qt Xlsx example. 5 | \ingroup qtxlsx-examples 6 | 7 | This example demonstrates how to create a new 8 | .xlsx file containing some basic data and calculations 9 | with Qt Xlsx Library. So lets see how this is achieved. 10 | \image hello.png 11 | 12 | This creates a new instance of the all important Document 13 | class which gives you access to the Excel workbook and worksheets. 14 | \snippet hello/main.cpp 0 15 | 16 | A default worksheet have been created by Document. Let's start 17 | by adding some basic data. 18 | \snippet hello/main.cpp 1 19 | 20 | Now save the file and all its components. 21 | \snippet hello/main.cpp 2 22 | */ 23 | -------------------------------------------------------------------------------- /examples/xlsx/hello/hello.pro: -------------------------------------------------------------------------------- 1 | TARGET = hello 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT+=xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | -------------------------------------------------------------------------------- /examples/xlsx/hello/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xlsxdocument.h" 3 | 4 | int main() 5 | { 6 | //![0] 7 | QXlsx::Document xlsx; 8 | //![0] 9 | 10 | //![1] 11 | xlsx.write("A1", "Hello Qt!"); 12 | xlsx.write("A2", 12345); 13 | xlsx.write("A3", "=44+33"); 14 | xlsx.write("A4", true); 15 | xlsx.write("A5", "http://qt-project.org"); 16 | xlsx.write("A6", QDate(2013, 12, 27)); 17 | xlsx.write("A7", QTime(6, 30)); 18 | //![1] 19 | 20 | //![2] 21 | xlsx.save(); 22 | //![2] 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /examples/xlsx/hyperlinks/hyperlinks.pro: -------------------------------------------------------------------------------- 1 | TARGET = hyperlinks 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT+=xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | -------------------------------------------------------------------------------- /examples/xlsx/hyperlinks/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xlsxdocument.h" 3 | 4 | int main() 5 | { 6 | //![0] 7 | QXlsx::Document xlsx; 8 | //![0] 9 | 10 | //![1] 11 | xlsx.write("A1", "http://qt-project.org"); 12 | xlsx.write("A2", "http://qt-project.org/wiki#0f68b904e33d9ac04605aecc958bcf52"); 13 | xlsx.write("A3", "mailto:info@qt-project.org"); 14 | xlsx.write("A4", "file:///C:/User/test/abc.txt"); 15 | //![1] 16 | 17 | //![2] 18 | xlsx.save(); 19 | //![2] 20 | 21 | QXlsx::Document xlsx2("Book1.xlsx"); 22 | xlsx2.saveAs("Book2.xlsx"); 23 | 24 | return 0; 25 | } 26 | -------------------------------------------------------------------------------- /examples/xlsx/image/image.pro: -------------------------------------------------------------------------------- 1 | TARGET = image 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT += xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | -------------------------------------------------------------------------------- /examples/xlsx/image/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xlsxdocument.h" 3 | 4 | int main(int argc, char** argv) 5 | { 6 | QGuiApplication(argc, argv); 7 | 8 | QXlsx::Document xlsx; 9 | QImage image(40, 30, QImage::Format_RGB32); 10 | image.fill(Qt::green); 11 | for (int i=0; i<10; ++i) 12 | xlsx.insertImage(10*i, 5, image); 13 | xlsx.saveAs("Book1.xlsx"); 14 | 15 | QXlsx::Document xlsx2("Book1.xlsx"); 16 | xlsx2.saveAs("Book2.xlsx"); 17 | 18 | return 0; 19 | } 20 | -------------------------------------------------------------------------------- /examples/xlsx/mergecells/doc/images/xlsx-mergecells.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/VSRonin/QtXlsxWriter/01eb671564b05bd11470046d0eaeef6d806bb9e6/examples/xlsx/mergecells/doc/images/xlsx-mergecells.png -------------------------------------------------------------------------------- /examples/xlsx/mergecells/doc/src/mergecells.qdoc: -------------------------------------------------------------------------------- 1 | /*! 2 | \example mergecells 3 | \title Merge Cells Example 4 | \brief Demonstrates how to merge cells 5 | \ingroup qtxlsx-examples 6 | 7 | This example demonstrates how to generate a 8 | simplest .xlsx file which contians merged cells with 9 | Qt Xlsx Library. 10 | 11 | \image xlsx-mergecells.png 12 | 13 | Create an format which will be applied to the merged cells: 14 | \snippet mergecells/main.cpp 0 15 | 16 | Merge cells. 17 | \snippet mergecells/main.cpp 1 18 | 19 | */ 20 | -------------------------------------------------------------------------------- /examples/xlsx/mergecells/main.cpp: -------------------------------------------------------------------------------- 1 | #include "xlsxdocument.h" 2 | #include "xlsxformat.h" 3 | 4 | QTXLSX_USE_NAMESPACE 5 | 6 | int main() 7 | { 8 | Document xlsx; 9 | //![0] 10 | Format format; 11 | format.setHorizontalAlignment(Format::AlignHCenter); 12 | format.setVerticalAlignment(Format::AlignVCenter); 13 | //![0] 14 | //![1] 15 | xlsx.write("B4", "Hello Qt!"); 16 | xlsx.mergeCells("B4:F6", format); 17 | xlsx.write("B8", 1); 18 | xlsx.mergeCells("B8:C21", format); 19 | xlsx.write("E8", 2); 20 | xlsx.mergeCells("E8:F21", format); 21 | //![1] 22 | xlsx.save(); 23 | 24 | return 0; 25 | } 26 | 27 | -------------------------------------------------------------------------------- /examples/xlsx/mergecells/mergecells.pro: -------------------------------------------------------------------------------- 1 | TARGET = mergecells 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT += xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | -------------------------------------------------------------------------------- /examples/xlsx/numberformat/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xlsxdocument.h" 3 | #include "xlsxformat.h" 4 | 5 | int main(int argc, char** argv) 6 | { 7 | QGuiApplication(argc, argv); 8 | 9 | QXlsx::Document xlsx; 10 | xlsx.setColumnWidth(1, 4, 20.0); 11 | 12 | QXlsx::Format header; 13 | header.setFontBold(true); 14 | header.setFontSize(20); 15 | 16 | //Custom number formats 17 | QStringList numFormats; 18 | numFormats<<"Qt #" 19 | <<"yyyy-mmm-dd" 20 | <<"$ #,##0.00" 21 | <<"[red]0.00"; 22 | xlsx.write(1, 1, "Raw data", header); 23 | xlsx.write(1, 2, "Format", header); 24 | xlsx.write(1, 3, "Shown value", header); 25 | for (int i=0; i 2 | #include "xlsxdocument.h" 3 | #include "xlsxrichstring.h" 4 | #include "xlsxworkbook.h" 5 | #include "xlsxformat.h" 6 | 7 | int main() 8 | { 9 | //![0] 10 | QXlsx::Document xlsx; 11 | //![0] 12 | 13 | //![1] 14 | QXlsx::Format blue; 15 | blue.setFontColor(Qt::blue); 16 | QXlsx::Format red; 17 | red.setFontColor(Qt::red); 18 | red.setFontSize(15); 19 | QXlsx::Format bold; 20 | bold.setFontBold(true); 21 | 22 | QXlsx::RichString rich; 23 | rich.addFragment("Hello ", blue); 24 | rich.addFragment("Qt ", red); 25 | rich.addFragment("Xlsx", bold); 26 | xlsx.write("B2", rich); 27 | 28 | xlsx.workbook()->setHtmlToRichStringEnabled(true); 29 | xlsx.write("B4", "Hello Qt Xlsx"); 30 | 31 | xlsx.write("B6", "Qt Xlsx"); 32 | 33 | //![1] 34 | 35 | //![2] 36 | xlsx.saveAs("Test1.xlsx"); 37 | //![2] 38 | 39 | QXlsx::Document("Test1.xlsx"); 40 | xlsx.saveAs("Test2.xlsx"); 41 | 42 | return 0; 43 | } 44 | -------------------------------------------------------------------------------- /examples/xlsx/richtext/richtext.pro: -------------------------------------------------------------------------------- 1 | TARGET = hello 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT+=xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | -------------------------------------------------------------------------------- /examples/xlsx/rowcolumn/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xlsxdocument.h" 3 | #include "xlsxformat.h" 4 | 5 | int main() 6 | { 7 | QXlsx::Document xlsx; 8 | xlsx.write(1, 2, "Row:0, Col:2 ==> (C1)"); 9 | 10 | //Set the height of the first row to 50.0(points) 11 | xlsx.setRowHeight(1, 50.0); 12 | 13 | //Set the width of the third column to 40.0(chars) 14 | xlsx.setColumnWidth(3, 3, 40.0); 15 | 16 | //Set style for the row 11th. 17 | QXlsx::Format format1; 18 | format1.setFontBold(true); 19 | format1.setFontColor(QColor(Qt::blue)); 20 | format1.setFontSize(20); 21 | xlsx.write(11, 1, "Hello Row Style"); 22 | xlsx.write(11, 6, "Blue Color"); 23 | xlsx.setRowFormat(11, format1); 24 | xlsx.setRowHeight(11, 41); 25 | 26 | //Set style for the col [9th, 16th) 27 | QXlsx::Format format2; 28 | format2.setFontBold(true); 29 | format2.setFontColor(QColor(Qt::magenta)); 30 | for (int row=12; row<=30; row++) 31 | for (int col=9; col<=15; col++) 32 | xlsx.write(row, col, row+col); 33 | xlsx.setColumnWidth(9, 16, 5.0); 34 | xlsx.setColumnFormat(9, 16, format2); 35 | 36 | xlsx.save(); 37 | return 0; 38 | } 39 | -------------------------------------------------------------------------------- /examples/xlsx/rowcolumn/rowcolumn.pro: -------------------------------------------------------------------------------- 1 | TARGET = image 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT += xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | -------------------------------------------------------------------------------- /examples/xlsx/style/doc/src/style.qdoc: -------------------------------------------------------------------------------- 1 | /*! 2 | \title Qt Xlsx Examples - Style 3 | \example style 4 | \title Xlsx Style Example 5 | \brief This is a simplest xlsx examples. 6 | \ingroup qtxlsx-examples 7 | 8 | This example demonstrates how to generate a 9 | .xlsx file with Qt Xlsx Library. 10 | */ 11 | -------------------------------------------------------------------------------- /examples/xlsx/style/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xlsxdocument.h" 3 | #include "xlsxformat.h" 4 | 5 | int main() 6 | { 7 | QXlsx::Document xlsx; 8 | QXlsx::Format format1; 9 | format1.setFontColor(QColor(Qt::red)); 10 | format1.setFontSize(15); 11 | format1.setHorizontalAlignment(QXlsx::Format::AlignHCenter); 12 | format1.setBorderStyle(QXlsx::Format::BorderDashDotDot); 13 | xlsx.write("A1", "Hello Qt!", format1); 14 | xlsx.write("B3", 12345, format1); 15 | 16 | QXlsx::Format format2; 17 | format2.setFontBold(true); 18 | format2.setFontUnderline(QXlsx::Format::FontUnderlineDouble); 19 | format2.setFillPattern(QXlsx::Format::PatternLightUp); 20 | xlsx.write("C5", "=44+33", format2); 21 | xlsx.write("D7", true, format2); 22 | 23 | QXlsx::Format format3; 24 | format3.setFontBold(true); 25 | format3.setFontColor(QColor(Qt::blue)); 26 | format3.setFontSize(20); 27 | xlsx.write(11, 1, "Hello Row Style"); 28 | xlsx.write(11, 6, "Blue Color"); 29 | xlsx.setRowFormat(11, 41, format3); 30 | 31 | QXlsx::Format format4; 32 | format4.setFontBold(true); 33 | format4.setFontColor(QColor(Qt::magenta)); 34 | for (int row=21; row<=40; row++) 35 | for (int col=9; col<16; col++) 36 | xlsx.write(row, col, row+col); 37 | xlsx.setColumnFormat(9, 16, format4); 38 | 39 | xlsx.write("A5", QDate(2013, 8, 29)); 40 | 41 | QXlsx::Format format6; 42 | format6.setPatternBackgroundColor(QColor(Qt::green)); 43 | xlsx.write("A6", "Background color: green", format6); 44 | 45 | xlsx.saveAs("book1.xlsx"); 46 | 47 | return 0; 48 | } 49 | -------------------------------------------------------------------------------- /examples/xlsx/style/style.pro: -------------------------------------------------------------------------------- 1 | TARGET = style 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT += xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | -------------------------------------------------------------------------------- /examples/xlsx/worksheetoperations/doc/src/worksheetoperations.qdoc: -------------------------------------------------------------------------------- 1 | /*! 2 | \example worksheetoperations 3 | \title Worksheet Operations Example 4 | \brief Copy, delete, move worksheet 5 | \ingroup qtxlsx-examples 6 | 7 | This example demonstrates how to copy, delete, move worksheet. 8 | */ 9 | -------------------------------------------------------------------------------- /examples/xlsx/worksheetoperations/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xlsxdocument.h" 3 | #include "xlsxabstractsheet.h" 4 | 5 | QTXLSX_USE_NAMESPACE 6 | 7 | int main() 8 | { 9 | //![Create a xlsx file] 10 | Document xlsx; 11 | 12 | for (int i=1; i<20; ++i) { 13 | for (int j=1; j<15; ++j) 14 | xlsx.write(i, j, QString("R %1 C %2").arg(i).arg(j)); 15 | } 16 | xlsx.addSheet(); 17 | xlsx.write(2, 2, "Hello Qt Xlsx"); 18 | xlsx.addSheet(); 19 | xlsx.write(3, 3, "This will be deleted..."); 20 | 21 | xlsx.addSheet("HiddenSheet"); 22 | xlsx.currentSheet()->setHidden(true); 23 | xlsx.write("A1", "This sheet is hidden."); 24 | 25 | xlsx.addSheet("VeryHiddenSheet"); 26 | xlsx.sheet("VeryHiddenSheet")->setSheetState(AbstractSheet::SS_VeryHidden); 27 | xlsx.write("A1", "This sheet is very hidden."); 28 | 29 | xlsx.save();//Default name is "Book1.xlsx" 30 | //![Create a xlsx file] 31 | 32 | Document xlsx2("Book1.xlsx"); 33 | //![add_copy_move_delete] 34 | xlsx2.renameSheet("Sheet1", "TheFirstSheet"); 35 | 36 | xlsx2.copySheet("TheFirstSheet", "CopyOfTheFirst"); 37 | 38 | xlsx2.selectSheet("CopyOfTheFirst"); 39 | xlsx2.write(25, 2, "On the Copy Sheet"); 40 | 41 | xlsx2.deleteSheet("Sheet3"); 42 | 43 | xlsx2.moveSheet("Sheet2", 0); 44 | //![add_copy_move_delete] 45 | 46 | //![show_hidden_sheets] 47 | xlsx2.sheet("HiddenSheet")->setVisible(true); 48 | xlsx2.sheet("VeryHiddenSheet")->setVisible(true); 49 | //![show_hidden_sheets] 50 | 51 | xlsx2.saveAs("Book2.xlsx"); 52 | return 0; 53 | } 54 | -------------------------------------------------------------------------------- /examples/xlsx/worksheetoperations/worksheetoperations.pro: -------------------------------------------------------------------------------- 1 | TARGET = worksheetoperations 2 | 3 | #include(../../../src/xlsx/qtxlsx.pri) 4 | QT+=xlsx 5 | 6 | CONFIG += console 7 | CONFIG += install_ok 8 | CONFIG -= app_bundle 9 | 10 | SOURCES += main.cpp 11 | -------------------------------------------------------------------------------- /examples/xlsx/xlsx.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS = hello \ 3 | extractdata \ 4 | style \ 5 | documentproperty \ 6 | image \ 7 | mergecells \ 8 | rowcolumn \ 9 | numberformat \ 10 | datavalidation \ 11 | definename \ 12 | formulas \ 13 | richtext \ 14 | conditionalformatting \ 15 | worksheetoperations \ 16 | hyperlinks \ 17 | chart \ 18 | chartsheet \ 19 | calendar \ 20 | demo 21 | 22 | qtHaveModule(widgets): SUBDIRS += xlsxwidget 23 | 24 | -------------------------------------------------------------------------------- /examples/xlsx/xlsxwidget/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include "xlsxdocument.h" 3 | #include "xlsxworksheet.h" 4 | #include "xlsxcellrange.h" 5 | #include "xlsxsheetmodel.h" 6 | 7 | using namespace QXlsx; 8 | 9 | int main(int argc, char **argv) 10 | { 11 | QApplication app(argc, argv); 12 | 13 | //![0] 14 | QString filePath = QFileDialog::getOpenFileName(0, "Open xlsx file", QString(), "*.xlsx"); 15 | if (filePath.isEmpty()) 16 | return -1; 17 | //![0] 18 | 19 | //![1] 20 | QTabWidget tabWidget; 21 | tabWidget.setWindowTitle(filePath + " - Qt Xlsx Demo"); 22 | tabWidget.setTabPosition(QTabWidget::South); 23 | //![1] 24 | 25 | //![2] 26 | Document xlsx(filePath); 27 | foreach (QString sheetName, xlsx.sheetNames()) { 28 | Worksheet *sheet = dynamic_cast(xlsx.sheet(sheetName)); 29 | if (sheet) { 30 | QTableView *view = new QTableView(&tabWidget); 31 | view->setModel(new SheetModel(sheet, view)); 32 | foreach (CellRange range, sheet->mergedCells()) 33 | view->setSpan(range.firstRow()-1, range.firstColumn()-1, range.rowCount(), range.columnCount()); 34 | tabWidget.addTab(view, sheetName); 35 | } 36 | } 37 | //![2] 38 | 39 | tabWidget.show(); 40 | return app.exec(); 41 | } 42 | -------------------------------------------------------------------------------- /examples/xlsx/xlsxwidget/xlsxsheetmodel.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | 26 | #ifndef QXLSX_XLSXSHEETMODEL_H 27 | #define QXLSX_XLSXSHEETMODEL_H 28 | 29 | #include "xlsxglobal.h" 30 | #include 31 | 32 | QT_BEGIN_NAMESPACE_XLSX 33 | 34 | class Worksheet; 35 | class SheetModelPrivate; 36 | 37 | class SheetModel : public QAbstractTableModel 38 | { 39 | Q_OBJECT 40 | Q_DECLARE_PRIVATE(SheetModel) 41 | public: 42 | explicit SheetModel(Worksheet *sheet, QObject *parent = 0); 43 | ~SheetModel(); 44 | 45 | int rowCount(const QModelIndex &parent = QModelIndex()) const; 46 | int columnCount(const QModelIndex &parent = QModelIndex()) const; 47 | Qt::ItemFlags flags(const QModelIndex & index) const; 48 | QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; 49 | QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; 50 | bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole); 51 | 52 | Worksheet *sheet() const; 53 | signals: 54 | 55 | public slots: 56 | 57 | private: 58 | SheetModelPrivate * const d_ptr; 59 | }; 60 | 61 | QT_END_NAMESPACE_XLSX 62 | 63 | #endif // QXLSX_XLSXSHEETMODEL_H 64 | -------------------------------------------------------------------------------- /examples/xlsx/xlsxwidget/xlsxsheetmodel_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | 26 | #ifndef XLSXSHEETMODEL_P_H 27 | #define XLSXSHEETMODEL_P_H 28 | 29 | // 30 | // W A R N I N G 31 | // ------------- 32 | // 33 | // This file is not part of the Qt Xlsx API. It exists for the convenience 34 | // of the Qt Xlsx. This header file may change from 35 | // version to version without notice, or even be removed. 36 | // 37 | // We mean it. 38 | // 39 | 40 | #include "xlsxsheetmodel.h" 41 | 42 | QT_BEGIN_NAMESPACE_XLSX 43 | 44 | class SheetModelPrivate 45 | { 46 | Q_DECLARE_PUBLIC(SheetModel) 47 | public: 48 | SheetModelPrivate(SheetModel *p); 49 | 50 | Worksheet *sheet; 51 | SheetModel *q_ptr; 52 | }; 53 | 54 | QT_END_NAMESPACE_XLSX 55 | 56 | #endif // XLSXSHEETMODEL_P_H 57 | -------------------------------------------------------------------------------- /examples/xlsx/xlsxwidget/xlsxwidget.pro: -------------------------------------------------------------------------------- 1 | TARGET = xlsxwidget 2 | QT += widgets 3 | 4 | #include(../../../src/xlsx/qtxlsx.pri) 5 | QT+= xlsx 6 | CONFIG += install_ok 7 | 8 | SOURCES += main.cpp \ 9 | xlsxsheetmodel.cpp 10 | 11 | HEADERS += \ 12 | xlsxsheetmodel.h \ 13 | xlsxsheetmodel_p.h 14 | -------------------------------------------------------------------------------- /qtxlsx.pro: -------------------------------------------------------------------------------- 1 | load(qt_parts) 2 | -------------------------------------------------------------------------------- /src/src.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | 3 | SUBDIRS = xlsx 4 | -------------------------------------------------------------------------------- /src/xlsx/doc/qtxlsx.qdocconf: -------------------------------------------------------------------------------- 1 | include($QT_INSTALL_DOCS/global/qt-html-templates-offline.qdocconf) 2 | include($QT_INSTALL_DOCS/global/qt-module-defaults.qdocconf) 3 | 4 | project = QtXlsx 5 | description = Qt Xlsx Reference Documentation 6 | url = http://qtxlsx.debao.me 7 | version = $QT_VERSION 8 | 9 | qhp.projects = QtXlsx 10 | 11 | qhp.QtXlsx.file = qtxlsx.qhp 12 | qhp.QtXlsx.namespace = me.debao.qtxlsx.$QT_VERSION_TAG 13 | qhp.QtXlsx.virtualFolder = qtxlsx 14 | qhp.QtXlsx.indexTitle = Qt Xlsx 15 | qhp.QtXlsx.indexRoot = 16 | 17 | qhp.QtXlsx.filterAttributes = qtxlsx $QT_VERSION qtrefdoc 18 | qhp.QtXlsx.customFilters.Qt.name = QtXlsx $QT_VERSION 19 | qhp.QtXlsx.customFilters.Qt.filterAttributes = qtxlsx $QT_VERSION 20 | qhp.QtXlsx.subprojects = overviews classes qmltypes examples 21 | qhp.QtXlsx.subprojects.overviews.title = Overview 22 | qhp.QtXlsx.subprojects.overviews.indexTitle = Qt Xlsx 23 | qhp.QtXlsx.subprojects.overviews.selectors = fake:page,group,module 24 | qhp.QtXlsx.subprojects.classes.title = C++ Classes 25 | qhp.QtXlsx.subprojects.classes.indexTitle = Qt Xlsx C++ Classes 26 | qhp.QtXlsx.subprojects.classes.selectors = class fake:headerfile 27 | qhp.QtXlsx.subprojects.classes.sortPages = true 28 | qhp.QtXlsx.subprojects.examples.title = Examples 29 | qhp.QtXlsx.subprojects.examples.indexTitle = Qt Xlsx Examples 30 | qhp.QtXlsx.subprojects.examples.selectors = fake:example 31 | 32 | tagfile = ../../../doc/qtxlsx/qtxlsx.tags 33 | 34 | headerdirs += .. 35 | 36 | sourcedirs += .. 37 | 38 | exampledirs += ../../../examples/xlsx \ 39 | snippets/ 40 | 41 | # Specify the install path under QT_INSTALL_EXAMPLES 42 | examplesinstallpath = xlsx 43 | 44 | imagedirs += images 45 | 46 | depends += qtcore qtdoc qtgui 47 | 48 | HTML.footer = \ 49 | " \n" \ 50 | " \n" \ 51 | " \n" \ 52 | " \n" \ 53 | "\n" \ 54 | "
\n" \ 55 | "
\n" \ 56 | "
\n" \ 57 | "

\n" \ 58 | " © 2013-2014 Debao Zhang. \n" \ 59 | " Documentation contributions included herein are the copyrights of\n" \ 60 | " their respective owners.

\n" \ 61 | "

\n" \ 62 | " The documentation provided herein is licensed under the terms of the\n" \ 63 | " GNU Free Documentation\n" \ 64 | " License version 1.3 as published by the Free Software Foundation.

\n" \ 65 | "

\n" \ 66 | " Documentation sources may be obtained from \n" \ 67 | " github.com/dbzhang800.

\n" \ 68 | "

\n" \ 69 | " Qt and their respective logos are trademarks of Digia Plc \n" \ 70 | " in Finland and/or other countries worldwide. All other trademarks are property\n" \ 71 | " of their respective owners. Privacy Policy

\n" \ 73 | "
\n" \ 74 | "
\n" \ 75 | "
\n" \ 76 | -------------------------------------------------------------------------------- /src/xlsx/doc/snippets/doc_src_qtxlsx.cpp: -------------------------------------------------------------------------------- 1 | 2 | //! [0] 3 | #include 4 | //! [0] 5 | 6 | //! [1] 7 | #include 8 | //! [1] 9 | -------------------------------------------------------------------------------- /src/xlsx/doc/snippets/doc_src_qtxlsx.pro: -------------------------------------------------------------------------------- 1 | #! [1] 2 | QT += xlsx 3 | #! [1] 4 | -------------------------------------------------------------------------------- /src/xlsx/doc/src/examples.qdoc: -------------------------------------------------------------------------------- 1 | /*! 2 | \group qtxlsx-examples 3 | \title Qt Xlsx Examples 4 | \brief Examples for the Qt Xlsx module 5 | \ingroup all-examples 6 | 7 | Qt Xlsx comes with the following examples: 8 | */ 9 | -------------------------------------------------------------------------------- /src/xlsx/doc/src/qtxlsx-index.qdoc: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013 Debao Zhang 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 | 26 | /*! 27 | \title Qt Xlsx 28 | \page index.html 29 | \brief Qt Xlsx provides functionality for handling .xlsx files. 30 | 31 | The \l{Qt Xlsx C++ Classes}{Qt Xlsx Module} provides a set of classes to read and write Excel files. It doesn't require 32 | Microsoft Excel and can be used in any platform that Qt5 supported. The library can be used to 33 | 34 | \list 35 | \li \l{Hello QtXlsx Example}{Generate a new .xlsx file from scratch} 36 | \li \l{Extract Data Example}{Extract data from an existing .xlsx file} 37 | \li Edit an existing .xlsx file 38 | \endlist 39 | 40 | \image xlsx_demo.gif 41 | 42 | \table 43 | \row 44 | \li Source code: \li \l{https://github.com/dbzhang800/QtXlsxWriter} 45 | \row 46 | \li Issures: \li \l{https://github.com/dbzhang800/QtXlsxWriter/issues} 47 | \row 48 | \li License: \li MIT 49 | \endtable 50 | 51 | \section1 Getting Started 52 | 53 | To include the definitions of the module's classes, using the following directive: 54 | 55 | \code 56 | #include 57 | \endcode 58 | 59 | To link against the module, add this line to your qmake .pro file: 60 | 61 | \code 62 | QT += xlsx 63 | \endcode 64 | 65 | More information can be found in \l{Qt Xlsx Build} page. 66 | 67 | \section1 Related information 68 | \list 69 | \li \l{Qt Xlsx C++ Classes} 70 | \li \l{Qt Xlsx Examples} 71 | \endlist 72 | */ 73 | -------------------------------------------------------------------------------- /src/xlsx/doc/src/qtxlsx.qdoc: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013 Debao Zhang 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 | 26 | /*! 27 | \module QtXlsx 28 | \title Qt Xlsx C++ Classes 29 | \ingroup modules 30 | 31 | \brief The Qt Xlsx module provides functionality for handling .xlsx files. 32 | 33 | .xlsx is a zipped, XML-based file format developed by Microsoft for 34 | representing spreadsheets. 35 | */ 36 | 37 | -------------------------------------------------------------------------------- /src/xlsx/doc/src/usage.qdoc: -------------------------------------------------------------------------------- 1 | /*! 2 | \page building 3 | \title Qt Xlsx Build 4 | 5 | \note QZipWriter and QZipReader which live in gui-private is used in 6 | this library. For linux user, if your Qt is installed through package 7 | manager tools such "apt-get", make sure that you have installed the Qt5 8 | develop package *qtbase5-private-dev* ; 9 | if you Qt is built from source by yourself, 10 | or download from qt-project.org directly, nothing need to do. 11 | 12 | \section1 Usage(1): Use Xlsx as Qt5's addon module 13 | 14 | 1. Download the source code from \l {https://github.com/dbzhang800/QtXlsxWriter/archive/master.zip} {github.com}. 15 | 16 | 2. Put the source code in any directory you like. At the toplevel directory run 17 | 18 | \note Perl is needed in this step. 19 | 20 | \code 21 | qmake 22 | make 23 | make install 24 | \endcode 25 | 26 | The library, the header files, and others will be installed to your system. 27 | 28 | 3. Add following line to your qmake's project file: 29 | 30 | \code 31 | QT += xlsx 32 | \endcode 33 | 34 | 4. Then, using Qt Xlsx in your code 35 | 36 | \code 37 | #include "xlsxdocument.h" 38 | int main() 39 | { 40 | QXlsx::Document xlsx; 41 | xlsx.write("A1", "Hello Qt!"); 42 | xlsx.saveAs("Test.xlsx"); 43 | return 0; 44 | } 45 | \endcode 46 | 47 | \section1 Usage(2): Use source code directly 48 | 49 | The package contains a qtxlsx.pri file that allows you to integrate 50 | the component into applications that use qmake for the build step. 51 | 52 | 1. Download the source code from \l {https://github.com/dbzhang800/QtXlsxWriter/archive/master.zip} {github.com} 53 | 54 | 2. Put the source code in any directory you like. For example, 3rdparty: 55 | 56 | \code 57 | |-- project.pro 58 | |-- .... 59 | |-- 3rdparty\ 60 | | |-- qtxlsx\ 61 | | | 62 | \endcode 63 | 64 | 3. Add following line to your qmake project file: 65 | 66 | \code 67 | include(3rdparty/qtxlsx/src/xlsx/qtxlsx.pri) 68 | \endcode 69 | 70 | \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: 71 | 72 | \code 73 | include(qtxlsx.pri) 74 | \endcode 75 | 76 | \note If you do not use qmake, you need to define the following macro manually 77 | 78 | \code 79 | XLSX_NO_LIB 80 | \endcode 81 | 82 | 4. Then, using Qt Xlsx in your code 83 | */ 84 | -------------------------------------------------------------------------------- /src/xlsx/qtxlsx.pri: -------------------------------------------------------------------------------- 1 | INCLUDEPATH += $$PWD 2 | DEPENDPATH += $$PWD 3 | 4 | QT += core gui gui-private 5 | !build_xlsx_lib:DEFINES += XLSX_NO_LIB 6 | 7 | HEADERS += $$PWD/xlsxdocpropscore_p.h \ 8 | $$PWD/xlsxdocpropsapp_p.h \ 9 | $$PWD/xlsxrelationships_p.h \ 10 | $$PWD/xlsxutility_p.h \ 11 | $$PWD/xlsxsharedstrings_p.h \ 12 | $$PWD/xlsxcontenttypes_p.h \ 13 | $$PWD/xlsxtheme_p.h \ 14 | $$PWD/xlsxformat.h \ 15 | $$PWD/xlsxworkbook.h \ 16 | $$PWD/xlsxstyles_p.h \ 17 | $$PWD/xlsxabstractsheet.h \ 18 | $$PWD/xlsxabstractsheet_p.h \ 19 | $$PWD/xlsxworksheet.h \ 20 | $$PWD/xlsxworksheet_p.h \ 21 | $$PWD/xlsxchartsheet.h \ 22 | $$PWD/xlsxchartsheet_p.h \ 23 | $$PWD/xlsxzipwriter_p.h \ 24 | $$PWD/xlsxworkbook_p.h \ 25 | $$PWD/xlsxformat_p.h \ 26 | $$PWD/xlsxglobal.h \ 27 | $$PWD/xlsxdrawing_p.h \ 28 | $$PWD/xlsxzipreader_p.h \ 29 | $$PWD/xlsxdocument.h \ 30 | $$PWD/xlsxdocument_p.h \ 31 | $$PWD/xlsxcell.h \ 32 | $$PWD/xlsxcell_p.h \ 33 | $$PWD/xlsxdatavalidation.h \ 34 | $$PWD/xlsxdatavalidation_p.h \ 35 | $$PWD/xlsxcellreference.h \ 36 | $$PWD/xlsxcellrange.h \ 37 | $$PWD/xlsxrichstring_p.h \ 38 | $$PWD/xlsxrichstring.h \ 39 | $$PWD/xlsxconditionalformatting.h \ 40 | $$PWD/xlsxconditionalformatting_p.h \ 41 | $$PWD/xlsxcolor_p.h \ 42 | $$PWD/xlsxnumformatparser_p.h \ 43 | $$PWD/xlsxdrawinganchor_p.h \ 44 | $$PWD/xlsxmediafile_p.h \ 45 | $$PWD/xlsxabstractooxmlfile.h \ 46 | $$PWD/xlsxabstractooxmlfile_p.h \ 47 | $$PWD/xlsxchart.h \ 48 | $$PWD/xlsxchart_p.h \ 49 | $$PWD/xlsxsimpleooxmlfile_p.h \ 50 | $$PWD/xlsxcellformula.h \ 51 | $$PWD/xlsxcellformula_p.h 52 | 53 | SOURCES += $$PWD/xlsxdocpropscore.cpp \ 54 | $$PWD/xlsxdocpropsapp.cpp \ 55 | $$PWD/xlsxrelationships.cpp \ 56 | $$PWD/xlsxutility.cpp \ 57 | $$PWD/xlsxsharedstrings.cpp \ 58 | $$PWD/xlsxcontenttypes.cpp \ 59 | $$PWD/xlsxtheme.cpp \ 60 | $$PWD/xlsxformat.cpp \ 61 | $$PWD/xlsxstyles.cpp \ 62 | $$PWD/xlsxworkbook.cpp \ 63 | $$PWD/xlsxabstractsheet.cpp \ 64 | $$PWD/xlsxworksheet.cpp \ 65 | $$PWD/xlsxchartsheet.cpp \ 66 | $$PWD/xlsxzipwriter.cpp \ 67 | $$PWD/xlsxdrawing.cpp \ 68 | $$PWD/xlsxzipreader.cpp \ 69 | $$PWD/xlsxdocument.cpp \ 70 | $$PWD/xlsxcell.cpp \ 71 | $$PWD/xlsxdatavalidation.cpp \ 72 | $$PWD/xlsxcellreference.cpp \ 73 | $$PWD/xlsxcellrange.cpp \ 74 | $$PWD/xlsxrichstring.cpp \ 75 | $$PWD/xlsxconditionalformatting.cpp \ 76 | $$PWD/xlsxcolor.cpp \ 77 | $$PWD/xlsxnumformatparser.cpp \ 78 | $$PWD/xlsxdrawinganchor.cpp \ 79 | $$PWD/xlsxmediafile.cpp \ 80 | $$PWD/xlsxabstractooxmlfile.cpp \ 81 | $$PWD/xlsxchart.cpp \ 82 | $$PWD/xlsxsimpleooxmlfile.cpp \ 83 | $$PWD/xlsxcellformula.cpp 84 | 85 | -------------------------------------------------------------------------------- /src/xlsx/xlsx.pro: -------------------------------------------------------------------------------- 1 | TARGET = QtXlsx 2 | 3 | QMAKE_DOCS = $$PWD/doc/qtxlsx.qdocconf 4 | 5 | load(qt_module) 6 | 7 | CONFIG += build_xlsx_lib 8 | include(qtxlsx.pri) 9 | 10 | #Define this macro if you want to run tests, so more AIPs will get exported. 11 | #DEFINES += XLSX_TEST 12 | 13 | QMAKE_TARGET_COMPANY = "Debao Zhang" 14 | QMAKE_TARGET_COPYRIGHT = "Copyright (C) 2013-2014 Debao Zhang " 15 | QMAKE_TARGET_DESCRIPTION = ".Xlsx file wirter for Qt5" 16 | 17 | -------------------------------------------------------------------------------- /src/xlsx/xlsxabstractooxmlfile.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | 26 | #include "xlsxabstractooxmlfile.h" 27 | #include "xlsxabstractooxmlfile_p.h" 28 | 29 | #include 30 | #include 31 | 32 | QT_BEGIN_NAMESPACE_XLSX 33 | 34 | AbstractOOXmlFilePrivate::AbstractOOXmlFilePrivate(AbstractOOXmlFile *q, AbstractOOXmlFile::CreateFlag flag=AbstractOOXmlFile::F_NewFromScratch) 35 | :relationships(new Relationships), flag(flag), q_ptr(q) 36 | { 37 | 38 | } 39 | 40 | AbstractOOXmlFilePrivate::~AbstractOOXmlFilePrivate() 41 | { 42 | 43 | } 44 | 45 | /*! 46 | * \internal 47 | * 48 | * \class AbstractOOXmlFile 49 | * 50 | * Base class of all the ooxml part file. 51 | */ 52 | 53 | AbstractOOXmlFile::AbstractOOXmlFile(CreateFlag flag) 54 | :d_ptr(new AbstractOOXmlFilePrivate(this, flag)) 55 | { 56 | } 57 | 58 | AbstractOOXmlFile::AbstractOOXmlFile(AbstractOOXmlFilePrivate *d) 59 | :d_ptr(d) 60 | { 61 | 62 | } 63 | 64 | AbstractOOXmlFile::~AbstractOOXmlFile() 65 | { 66 | if (d_ptr->relationships) 67 | delete d_ptr->relationships; 68 | delete d_ptr; 69 | } 70 | 71 | QByteArray AbstractOOXmlFile::saveToXmlData() const 72 | { 73 | QByteArray data; 74 | QBuffer buffer(&data); 75 | buffer.open(QIODevice::WriteOnly); 76 | saveToXmlFile(&buffer); 77 | 78 | return data; 79 | } 80 | 81 | bool AbstractOOXmlFile::loadFromXmlData(const QByteArray &data) 82 | { 83 | QBuffer buffer; 84 | buffer.setData(data); 85 | buffer.open(QIODevice::ReadOnly); 86 | 87 | return loadFromXmlFile(&buffer); 88 | } 89 | 90 | /*! 91 | * \internal 92 | */ 93 | void AbstractOOXmlFile::setFilePath(const QString path) 94 | { 95 | Q_D(AbstractOOXmlFile); 96 | d->filePathInPackage = path; 97 | } 98 | 99 | /*! 100 | * \internal 101 | */ 102 | QString AbstractOOXmlFile::filePath() const 103 | { 104 | Q_D(const AbstractOOXmlFile); 105 | return d->filePathInPackage; 106 | } 107 | 108 | 109 | /*! 110 | * \internal 111 | */ 112 | Relationships *AbstractOOXmlFile::relationships() const 113 | { 114 | Q_D(const AbstractOOXmlFile); 115 | return d->relationships; 116 | } 117 | 118 | 119 | QT_END_NAMESPACE_XLSX 120 | -------------------------------------------------------------------------------- /src/xlsx/xlsxabstractooxmlfile.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | 26 | #ifndef QXLSX_XLSXABSTRACTOOXMLFILE_H 27 | #define QXLSX_XLSXABSTRACTOOXMLFILE_H 28 | 29 | #include "xlsxglobal.h" 30 | 31 | class QIODevice; 32 | class QByteArray; 33 | 34 | QT_BEGIN_NAMESPACE_XLSX 35 | class Relationships; 36 | class AbstractOOXmlFilePrivate; 37 | 38 | class Q_XLSX_EXPORT AbstractOOXmlFile 39 | { 40 | Q_DECLARE_PRIVATE(AbstractOOXmlFile) 41 | public: 42 | enum CreateFlag 43 | { 44 | F_NewFromScratch, 45 | F_LoadFromExists 46 | }; 47 | 48 | virtual ~AbstractOOXmlFile(); 49 | 50 | virtual void saveToXmlFile(QIODevice *device) const = 0; 51 | virtual bool loadFromXmlFile(QIODevice *device) = 0; 52 | 53 | virtual QByteArray saveToXmlData() const; 54 | virtual bool loadFromXmlData(const QByteArray &data); 55 | 56 | Relationships *relationships() const; 57 | 58 | void setFilePath(const QString path); 59 | QString filePath() const; 60 | 61 | protected: 62 | AbstractOOXmlFile(CreateFlag flag); 63 | AbstractOOXmlFile(AbstractOOXmlFilePrivate *d); 64 | 65 | AbstractOOXmlFilePrivate *d_ptr; 66 | }; 67 | 68 | QT_END_NAMESPACE_XLSX 69 | 70 | #endif // QXLSX_XLSXABSTRACTOOXMLFILE_H 71 | -------------------------------------------------------------------------------- /src/xlsx/xlsxabstractooxmlfile_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | 26 | #ifndef XLSXOOXMLFILE_P_H 27 | #define XLSXOOXMLFILE_P_H 28 | 29 | // 30 | // W A R N I N G 31 | // ------------- 32 | // 33 | // This file is not part of the Qt Xlsx API. It exists for the convenience 34 | // of the Qt Xlsx. This header file may change from 35 | // version to version without notice, or even be removed. 36 | // 37 | // We mean it. 38 | // 39 | 40 | #include "xlsxabstractooxmlfile.h" 41 | #include "xlsxrelationships_p.h" 42 | 43 | #include 44 | 45 | QT_BEGIN_NAMESPACE_XLSX 46 | 47 | class XLSX_AUTOTEST_EXPORT AbstractOOXmlFilePrivate 48 | { 49 | Q_DECLARE_PUBLIC(AbstractOOXmlFile) 50 | 51 | public: 52 | AbstractOOXmlFilePrivate(AbstractOOXmlFile *q, AbstractOOXmlFile::CreateFlag flag); 53 | virtual ~AbstractOOXmlFilePrivate(); 54 | 55 | QString filePathInPackage;//such as "xl/worksheets/sheet1.xml" 56 | //used when load the .xlsx file 57 | Relationships *relationships; 58 | AbstractOOXmlFile::CreateFlag flag; 59 | AbstractOOXmlFile *q_ptr; 60 | }; 61 | 62 | QT_END_NAMESPACE_XLSX 63 | 64 | #endif // XLSXOOXMLFILE_P_H 65 | -------------------------------------------------------------------------------- /src/xlsx/xlsxabstractsheet.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 XLSXABSTRACTSHEET_H 26 | #define XLSXABSTRACTSHEET_H 27 | 28 | #include "xlsxabstractooxmlfile.h" 29 | #include 30 | #include 31 | 32 | QT_BEGIN_NAMESPACE_XLSX 33 | class Workbook; 34 | class Drawing; 35 | class AbstractSheetPrivate; 36 | class Q_XLSX_EXPORT AbstractSheet : public AbstractOOXmlFile 37 | { 38 | Q_DECLARE_PRIVATE(AbstractSheet) 39 | public: 40 | enum SheetType { 41 | ST_WorkSheet, 42 | ST_ChartSheet, 43 | ST_DialogSheet, 44 | ST_MacroSheet 45 | }; 46 | 47 | enum SheetState { 48 | SS_Visible, 49 | SS_Hidden, 50 | SS_VeryHidden 51 | }; 52 | 53 | QString sheetName() const; 54 | SheetType sheetType() const; 55 | SheetState sheetState() const; 56 | void setSheetState(SheetState ss); 57 | bool isHidden() const; 58 | bool isVisible() const; 59 | void setHidden(bool hidden); 60 | void setVisible(bool visible); 61 | 62 | Workbook *workbook() const; 63 | 64 | protected: 65 | friend class Workbook; 66 | AbstractSheet(const QString &sheetName, int sheetId, Workbook *book, AbstractSheetPrivate *d); 67 | virtual AbstractSheet *copy(const QString &distName, int distId) const = 0; 68 | void setSheetName(const QString &sheetName); 69 | void setSheetType(SheetType type); 70 | int sheetId() const; 71 | 72 | Drawing *drawing() const; 73 | }; 74 | 75 | QT_END_NAMESPACE_XLSX 76 | #endif // XLSXABSTRACTSHEET_H 77 | -------------------------------------------------------------------------------- /src/xlsx/xlsxabstractsheet_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 XLSXABSTRACTSHEET_P_H 26 | #define XLSXABSTRACTSHEET_P_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | #include "xlsxabstractsheet.h" 41 | #include "xlsxabstractooxmlfile_p.h" 42 | 43 | #include 44 | 45 | namespace QXlsx { 46 | 47 | class XLSX_AUTOTEST_EXPORT AbstractSheetPrivate : public AbstractOOXmlFilePrivate 48 | { 49 | Q_DECLARE_PUBLIC(AbstractSheet) 50 | public: 51 | AbstractSheetPrivate(AbstractSheet *p, AbstractSheet::CreateFlag flag); 52 | ~AbstractSheetPrivate(); 53 | 54 | Workbook *workbook; 55 | QSharedPointer drawing; 56 | 57 | QString name; 58 | int id; 59 | AbstractSheet::SheetState sheetState; 60 | AbstractSheet::SheetType type; 61 | }; 62 | 63 | } 64 | #endif // XLSXABSTRACTSHEET_P_H 65 | -------------------------------------------------------------------------------- /src/xlsx/xlsxcell.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 QXLSX_XLSXCELL_H 26 | #define QXLSX_XLSXCELL_H 27 | 28 | #include "xlsxglobal.h" 29 | #include "xlsxformat.h" 30 | #include 31 | 32 | QT_BEGIN_NAMESPACE_XLSX 33 | 34 | class Worksheet; 35 | class Format; 36 | class CellFormula; 37 | class CellPrivate; 38 | class WorksheetPrivate; 39 | 40 | class Q_XLSX_EXPORT Cell 41 | { 42 | Q_DECLARE_PRIVATE(Cell) 43 | public: 44 | enum CellType { 45 | BooleanType, //t="b" 46 | NumberType, //t="n" (default) 47 | ErrorType, //t="e" 48 | SharedStringType, //t="s" 49 | StringType, //t="str" 50 | InlineStringType //t="inlineStr" 51 | }; 52 | 53 | CellType cellType() const; 54 | QVariant value() const; 55 | Format format() const; 56 | 57 | bool hasFormula() const; 58 | CellFormula formula() const; 59 | 60 | bool isDateTime() const; 61 | QDateTime dateTime() const; 62 | 63 | bool isRichString() const; 64 | 65 | ~Cell(); 66 | private: 67 | friend class Worksheet; 68 | friend class WorksheetPrivate; 69 | 70 | Cell(const QVariant &data=QVariant(), CellType type=NumberType, const Format &format=Format(), Worksheet *parent = Q_NULLPTR); 71 | Cell(const Cell * const cell); 72 | CellPrivate * const d_ptr; 73 | }; 74 | 75 | QT_END_NAMESPACE_XLSX 76 | 77 | #endif // QXLSX_XLSXCELL_H 78 | -------------------------------------------------------------------------------- /src/xlsx/xlsxcell_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 XLSXCELL_P_H 26 | #define XLSXCELL_P_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | #include "xlsxcell.h" 41 | #include "xlsxcellrange.h" 42 | #include "xlsxrichstring.h" 43 | #include "xlsxcellformula.h" 44 | #include 45 | #include 46 | 47 | QT_BEGIN_NAMESPACE_XLSX 48 | 49 | class CellPrivate 50 | { 51 | Q_DECLARE_PUBLIC(Cell) 52 | public: 53 | CellPrivate(Cell *p); 54 | CellPrivate(const CellPrivate * const cp); 55 | 56 | QVariant value; 57 | CellFormula formula; 58 | Cell::CellType cellType; 59 | Format format; 60 | 61 | RichString richString; 62 | 63 | Worksheet *parent; 64 | Cell *q_ptr; 65 | }; 66 | 67 | QT_END_NAMESPACE_XLSX 68 | 69 | #endif // XLSXCELL_P_H 70 | -------------------------------------------------------------------------------- /src/xlsx/xlsxcellformula.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 QXLSX_XLSXCELLFORMULA_H 26 | #define QXLSX_XLSXCELLFORMULA_H 27 | 28 | #include "xlsxglobal.h" 29 | #include 30 | 31 | class QXmlStreamWriter; 32 | class QXmlStreamReader; 33 | 34 | QT_BEGIN_NAMESPACE_XLSX 35 | 36 | class CellFormulaPrivate; 37 | class CellRange; 38 | class Worksheet; 39 | class WorksheetPrivate; 40 | 41 | class Q_XLSX_EXPORT CellFormula 42 | { 43 | public: 44 | enum FormulaType { 45 | NormalType, 46 | ArrayType, 47 | DataTableType, 48 | SharedType 49 | }; 50 | 51 | CellFormula(); 52 | CellFormula(const char *formula, FormulaType type=NormalType); 53 | CellFormula(const QString &formula, FormulaType type=NormalType); 54 | CellFormula(const QString &formula, const CellRange &ref, FormulaType type); 55 | CellFormula(const CellFormula &other); 56 | ~CellFormula(); 57 | CellFormula &operator =(const CellFormula &other); 58 | bool isValid() const; 59 | 60 | FormulaType formulaType() const; 61 | QString formulaText() const; 62 | CellRange reference() const; 63 | int sharedIndex() const; 64 | 65 | bool operator == (const CellFormula &formula) const; 66 | bool operator != (const CellFormula &formula) const; 67 | 68 | bool saveToXml(QXmlStreamWriter &writer) const; 69 | bool loadFromXml(QXmlStreamReader &reader); 70 | private: 71 | friend class Worksheet; 72 | friend class WorksheetPrivate; 73 | QExplicitlySharedDataPointer d; 74 | }; 75 | 76 | QT_END_NAMESPACE_XLSX 77 | 78 | #endif // QXLSX_XLSXCELLFORMULA_H 79 | -------------------------------------------------------------------------------- /src/xlsx/xlsxcellformula_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 XLSXCELLFORMULA_P_H 26 | #define XLSXCELLFORMULA_P_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | #include "xlsxcellformula.h" 41 | #include "xlsxcellrange.h" 42 | 43 | #include 44 | #include 45 | 46 | QT_BEGIN_NAMESPACE_XLSX 47 | 48 | class CellFormulaPrivate : public QSharedData 49 | { 50 | public: 51 | CellFormulaPrivate(const QString &formula, const CellRange &reference, CellFormula::FormulaType type); 52 | CellFormulaPrivate(const CellFormulaPrivate &other); 53 | ~CellFormulaPrivate(); 54 | 55 | QString formula; //formula contents 56 | CellFormula::FormulaType type; 57 | CellRange reference; 58 | bool ca; //Calculate Cell 59 | int si; //Shared group index 60 | }; 61 | 62 | QT_END_NAMESPACE_XLSX 63 | 64 | #endif // XLSXCELLFORMULA_P_H 65 | -------------------------------------------------------------------------------- /src/xlsx/xlsxcellrange.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 QXLSX_XLSXCELLRANGE_H 26 | #define QXLSX_XLSXCELLRANGE_H 27 | #include "xlsxglobal.h" 28 | #include "xlsxcellreference.h" 29 | 30 | QT_BEGIN_NAMESPACE_XLSX 31 | 32 | class Q_XLSX_EXPORT CellRange 33 | { 34 | public: 35 | CellRange(); 36 | CellRange(int firstRow, int firstColumn, int lastRow, int lastColumn); 37 | CellRange(const CellReference &topLeft, const CellReference &bottomRight); 38 | CellRange(const QString &range); 39 | CellRange(const char *range); 40 | CellRange(const CellRange &other); 41 | ~CellRange(); 42 | 43 | QString toString(bool row_abs=false, bool col_abs=false) const; 44 | bool isValid() const; 45 | inline void setFirstRow(int row) { top = row; } 46 | inline void setLastRow(int row) { bottom = row; } 47 | inline void setFirstColumn(int col) { left = col; } 48 | inline void setLastColumn(int col) { right = col; } 49 | inline int firstRow() const { return top; } 50 | inline int lastRow() const { return bottom; } 51 | inline int firstColumn() const { return left; } 52 | inline int lastColumn() const { return right; } 53 | inline int rowCount() const { return bottom - top + 1; } 54 | inline int columnCount() const { return right - left + 1; } 55 | inline CellReference topLeft() const { return CellReference(top, left); } 56 | inline CellReference topRight() const { return CellReference(top, right); } 57 | inline CellReference bottomLeft() const { return CellReference(bottom, left); } 58 | inline CellReference bottomRight() const { return CellReference(bottom, right); } 59 | 60 | inline bool operator ==(const CellRange &other) const 61 | { 62 | return top==other.top && bottom==other.bottom 63 | && left == other.left && right == other.right; 64 | } 65 | inline bool operator !=(const CellRange &other) const 66 | { 67 | return top!=other.top || bottom!=other.bottom 68 | || left != other.left || right != other.right; 69 | } 70 | private: 71 | void init(const QString &range); 72 | int top, left, bottom, right; 73 | }; 74 | 75 | QT_END_NAMESPACE_XLSX 76 | 77 | Q_DECLARE_TYPEINFO(QXlsx::CellRange, Q_MOVABLE_TYPE); 78 | 79 | #endif // QXLSX_XLSXCELLRANGE_H 80 | -------------------------------------------------------------------------------- /src/xlsx/xlsxcellreference.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 QXLSX_XLSXCELLREFERENCE_H 26 | #define QXLSX_XLSXCELLREFERENCE_H 27 | #include "xlsxglobal.h" 28 | 29 | QT_BEGIN_NAMESPACE_XLSX 30 | 31 | class Q_XLSX_EXPORT CellReference 32 | { 33 | public: 34 | CellReference(); 35 | CellReference(int row, int column); 36 | CellReference(const QString &cell); 37 | CellReference(const char *cell); 38 | CellReference(const CellReference &other); 39 | ~CellReference(); 40 | 41 | QString toString(bool row_abs=false, bool col_abs=false) const; 42 | static CellReference fromString(const QString &cell); 43 | bool isValid() const; 44 | inline void setRow(int row) { _row = row; } 45 | inline void setColumn(int col) { _column = col; } 46 | inline int row() const { return _row; } 47 | inline int column() const { return _column; } 48 | 49 | inline bool operator ==(const CellReference &other) const 50 | { 51 | return _row==other._row && _column==other._column; 52 | } 53 | inline bool operator !=(const CellReference &other) const 54 | { 55 | return _row!=other._row || _column!=other._column; 56 | } 57 | private: 58 | void init(const QString &cell); 59 | int _row, _column; 60 | }; 61 | 62 | QT_END_NAMESPACE_XLSX 63 | 64 | Q_DECLARE_TYPEINFO(QXlsx::CellReference, Q_MOVABLE_TYPE); 65 | 66 | #endif // QXLSX_XLSXCELLREFERENCE_H 67 | -------------------------------------------------------------------------------- /src/xlsx/xlsxchart.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | 26 | #ifndef QXLSX_CHART_H 27 | #define QXLSX_CHART_H 28 | 29 | #include "xlsxabstractooxmlfile.h" 30 | 31 | #include 32 | 33 | class QXmlStreamReader; 34 | class QXmlStreamWriter; 35 | 36 | QT_BEGIN_NAMESPACE_XLSX 37 | 38 | class AbstractSheet; 39 | class Worksheet; 40 | class ChartPrivate; 41 | class CellRange; 42 | class DrawingAnchor; 43 | 44 | class Q_XLSX_EXPORT Chart : public AbstractOOXmlFile 45 | { 46 | Q_DECLARE_PRIVATE(Chart) 47 | 48 | public: 49 | enum ChartType { 50 | CT_Area = 1, //Zero is internally used for unknown types 51 | CT_Area3D, 52 | CT_Line, 53 | CT_Line3D, 54 | CT_Stock, 55 | CT_Radar, 56 | CT_Scatter, 57 | CT_Pie, 58 | CT_Pie3D, 59 | CT_Doughnut, 60 | CT_Bar, 61 | CT_Bar3D, 62 | CT_OfPie, 63 | CT_Surface, 64 | CT_Surface3D, 65 | CT_Bubble 66 | }; 67 | 68 | ~Chart(); 69 | 70 | void addSeries(const CellRange &range, AbstractSheet *sheet = Q_NULLPTR); 71 | void setChartType(ChartType type); 72 | void setChartStyle(int id); 73 | 74 | void saveToXmlFile(QIODevice *device) const; 75 | bool loadFromXmlFile(QIODevice *device); 76 | 77 | private: 78 | friend class AbstractSheet; 79 | friend class Worksheet; 80 | friend class Chartsheet; 81 | friend class DrawingAnchor; 82 | 83 | Chart(AbstractSheet *parent, CreateFlag flag); 84 | }; 85 | 86 | QT_END_NAMESPACE_XLSX 87 | 88 | #endif // QXLSX_CHART_H 89 | 90 | -------------------------------------------------------------------------------- /src/xlsx/xlsxchart_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | 26 | #ifndef QXLSX_CHART_P_H 27 | #define QXLSX_CHART_P_H 28 | 29 | // 30 | // W A R N I N G 31 | // ------------- 32 | // 33 | // This file is not part of the Qt Xlsx API. It exists for the convenience 34 | // of the Qt Xlsx. This header file may change from 35 | // version to version without notice, or even be removed. 36 | // 37 | // We mean it. 38 | // 39 | 40 | #include "xlsxabstractooxmlfile_p.h" 41 | #include "xlsxchart.h" 42 | 43 | #include 44 | 45 | class QXmlStreamReader; 46 | class QXmlStreamWriter; 47 | 48 | namespace QXlsx { 49 | 50 | class XlsxSeries 51 | { 52 | public: 53 | //At present, we care about number cell ranges only! 54 | QString numberDataSource_numRef; //yval, val 55 | QString axDataSource_numRef; //xval, cat 56 | }; 57 | 58 | class XlsxAxis 59 | { 60 | public: 61 | enum Type 62 | { 63 | T_Cat, 64 | T_Val, 65 | T_Date, 66 | T_Ser 67 | }; 68 | 69 | enum Pos 70 | { 71 | Left, 72 | Right, 73 | Top, 74 | Bottom 75 | }; 76 | 77 | XlsxAxis(){} 78 | 79 | XlsxAxis(Type t, Pos p, int id, int crossId) 80 | :type(t), axisPos(p), axisId(id), crossAx(crossId) 81 | { 82 | } 83 | 84 | Type type; 85 | Pos axisPos; //l,r,b,t 86 | int axisId; 87 | int crossAx; 88 | }; 89 | 90 | class ChartPrivate : public AbstractOOXmlFilePrivate 91 | { 92 | Q_DECLARE_PUBLIC(Chart) 93 | 94 | public: 95 | ChartPrivate(Chart *q, Chart::CreateFlag flag); 96 | ~ChartPrivate(); 97 | 98 | bool loadXmlChart(QXmlStreamReader &reader); 99 | bool loadXmlPlotArea(QXmlStreamReader &reader); 100 | bool loadXmlXxxChart(QXmlStreamReader &reader); 101 | bool loadXmlSer(QXmlStreamReader &reader); 102 | QString loadXmlNumRef(QXmlStreamReader &reader); 103 | bool loadXmlAxis(QXmlStreamReader &reader); 104 | 105 | void saveXmlChart(QXmlStreamWriter &writer) const; 106 | void saveXmlPieChart(QXmlStreamWriter &writer) const; 107 | void saveXmlBarChart(QXmlStreamWriter &writer) const; 108 | void saveXmlLineChart(QXmlStreamWriter &writer) const; 109 | void saveXmlScatterChart(QXmlStreamWriter &writer) const; 110 | void saveXmlAreaChart(QXmlStreamWriter &writer) const; 111 | void saveXmlDoughnutChart(QXmlStreamWriter &writer) const; 112 | void saveXmlSer(QXmlStreamWriter &writer, XlsxSeries *ser, int id) const; 113 | void saveXmlAxes(QXmlStreamWriter &writer) const; 114 | 115 | Chart::ChartType chartType; 116 | 117 | QList > seriesList; 118 | QList > axisList; 119 | 120 | AbstractSheet *sheet; 121 | }; 122 | 123 | } // namespace QXlsx 124 | 125 | #endif // QXLSX_CHART_P_H 126 | -------------------------------------------------------------------------------- /src/xlsx/xlsxchartsheet.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 XLSXCHARTSHEET_H 26 | #define XLSXCHARTSHEET_H 27 | 28 | #include "xlsxabstractsheet.h" 29 | #include 30 | #include 31 | 32 | QT_BEGIN_NAMESPACE_XLSX 33 | class Workbook; 34 | class DocumentPrivate; 35 | class ChartsheetPrivate; 36 | class Chart; 37 | class Q_XLSX_EXPORT Chartsheet : public AbstractSheet 38 | { 39 | Q_DECLARE_PRIVATE(Chartsheet) 40 | public: 41 | 42 | ~Chartsheet(); 43 | Chart *chart(); 44 | 45 | private: 46 | friend class DocumentPrivate; 47 | friend class Workbook; 48 | Chartsheet(const QString &sheetName, int sheetId, Workbook *book, CreateFlag flag); 49 | Chartsheet *copy(const QString &distName, int distId) const; 50 | 51 | void saveToXmlFile(QIODevice *device) const; 52 | bool loadFromXmlFile(QIODevice *device); 53 | }; 54 | 55 | QT_END_NAMESPACE_XLSX 56 | #endif // XLSXCHARTSHEET_H 57 | -------------------------------------------------------------------------------- /src/xlsx/xlsxchartsheet_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 XLSXCHARTSHEET_P_H 26 | #define XLSXCHARTSHEET_P_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | #include "xlsxchartsheet.h" 41 | #include "xlsxabstractsheet_p.h" 42 | 43 | namespace QXlsx { 44 | 45 | class XLSX_AUTOTEST_EXPORT ChartsheetPrivate : public AbstractSheetPrivate 46 | { 47 | Q_DECLARE_PUBLIC(Chartsheet) 48 | public: 49 | ChartsheetPrivate(Chartsheet *p, Chartsheet::CreateFlag flag); 50 | ~ChartsheetPrivate(); 51 | 52 | Chart *chart; 53 | }; 54 | 55 | } 56 | #endif // XLSXCHARTSHEET_P_H 57 | -------------------------------------------------------------------------------- /src/xlsx/xlsxcolor_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | 26 | #ifndef QXLSX_XLSXCOLOR_P_H 27 | #define QXLSX_XLSXCOLOR_P_H 28 | 29 | // 30 | // W A R N I N G 31 | // ------------- 32 | // 33 | // This file is not part of the Qt Xlsx API. It exists for the convenience 34 | // of the Qt Xlsx. This header file may change from 35 | // version to version without notice, or even be removed. 36 | // 37 | // We mean it. 38 | // 39 | 40 | #include "xlsxglobal.h" 41 | #include 42 | #include 43 | 44 | class QXmlStreamWriter; 45 | class QXmlStreamReader; 46 | 47 | namespace QXlsx { 48 | 49 | class Styles; 50 | 51 | class Q_XLSX_EXPORT XlsxColor 52 | { 53 | public: 54 | explicit XlsxColor(const QColor &color = QColor()); 55 | explicit XlsxColor(const QString &theme, const QString &tint=QString()); 56 | explicit XlsxColor (int index); 57 | 58 | bool isThemeColor() const; 59 | bool isIndexedColor() const; 60 | bool isRgbColor() const; 61 | bool isInvalid() const; 62 | 63 | QColor rgbColor() const; 64 | int indexedColor() const; 65 | QStringList themeColor() const; 66 | 67 | operator QVariant() const; 68 | 69 | static QColor fromARGBString(const QString &c); 70 | static QString toARGBString(const QColor &c); 71 | 72 | bool saveToXml(QXmlStreamWriter &writer, const QString &node=QString()) const; 73 | bool loadFromXml(QXmlStreamReader &reader); 74 | 75 | private: 76 | QVariant val; 77 | }; 78 | 79 | #if !defined(QT_NO_DATASTREAM) 80 | Q_XLSX_EXPORT QDataStream &operator<<(QDataStream &, const XlsxColor &); 81 | Q_XLSX_EXPORT QDataStream &operator>>(QDataStream &, XlsxColor &); 82 | #endif 83 | 84 | #ifndef QT_NO_DEBUG_STREAM 85 | Q_XLSX_EXPORT QDebug operator<<(QDebug dbg, const XlsxColor &c); 86 | #endif 87 | 88 | } // namespace QXlsx 89 | 90 | Q_DECLARE_METATYPE(QXlsx::XlsxColor) 91 | 92 | #endif // QXLSX_XLSXCOLOR_P_H 93 | -------------------------------------------------------------------------------- /src/xlsx/xlsxcontenttypes_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 XLSXCONTENTTYPES_H 26 | #define XLSXCONTENTTYPES_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxabstractooxmlfile.h" 40 | 41 | #include 42 | #include 43 | #include 44 | 45 | class QIODevice; 46 | 47 | namespace QXlsx { 48 | 49 | class ContentTypes : public AbstractOOXmlFile 50 | { 51 | public: 52 | ContentTypes(CreateFlag flag); 53 | 54 | void addDefault(const QString &key, const QString &value); 55 | void addOverride(const QString &key, const QString &value); 56 | 57 | //Convenient funcation for addOverride() 58 | void addDocPropCore(); 59 | void addDocPropApp(); 60 | void addStyles(); 61 | void addTheme(); 62 | void addWorkbook(); 63 | void addWorksheetName(const QString &name); 64 | void addChartsheetName(const QString &name); 65 | void addChartName(const QString &name); 66 | void addDrawingName(const QString &name); 67 | void addCommentName(const QString &name); 68 | void addTableName(const QString &name); 69 | void addExternalLinkName(const QString &name); 70 | void addSharedString(); 71 | void addVmlName(); 72 | void addCalcChain(); 73 | void addVbaProject(); 74 | 75 | void clearOverrides(); 76 | 77 | void saveToXmlFile(QIODevice *device) const; 78 | bool loadFromXmlFile(QIODevice *device); 79 | private: 80 | QMap m_defaults; 81 | QMap m_overrides; 82 | 83 | QString m_package_prefix; 84 | QString m_document_prefix; 85 | }; 86 | 87 | } 88 | #endif // XLSXCONTENTTYPES_H 89 | -------------------------------------------------------------------------------- /src/xlsx/xlsxdatavalidation_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | 26 | #ifndef XLSXDATAVALIDATION_P_H 27 | #define XLSXDATAVALIDATION_P_H 28 | 29 | // 30 | // W A R N I N G 31 | // ------------- 32 | // 33 | // This file is not part of the Qt Xlsx API. It exists for the convenience 34 | // of the Qt Xlsx. This header file may change from 35 | // version to version without notice, or even be removed. 36 | // 37 | // We mean it. 38 | // 39 | 40 | #include "xlsxdatavalidation.h" 41 | #include 42 | 43 | QT_BEGIN_NAMESPACE_XLSX 44 | 45 | class Q_XLSX_EXPORT DataValidationPrivate : public QSharedData 46 | { 47 | public: 48 | DataValidationPrivate(); 49 | DataValidationPrivate(DataValidation::ValidationType type, DataValidation::ValidationOperator op, const QString &formula1, const QString &formula2, bool allowBlank); 50 | DataValidationPrivate(const DataValidationPrivate &other); 51 | ~DataValidationPrivate(); 52 | 53 | DataValidation::ValidationType validationType; 54 | DataValidation::ValidationOperator validationOperator; 55 | DataValidation::ErrorStyle errorStyle; 56 | bool allowBlank; 57 | bool isPromptMessageVisible; 58 | bool isErrorMessageVisible; 59 | QString formula1; 60 | QString formula2; 61 | QString errorMessage; 62 | QString errorMessageTitle; 63 | QString promptMessage; 64 | QString promptMessageTitle; 65 | QList ranges; 66 | }; 67 | 68 | QT_END_NAMESPACE_XLSX 69 | #endif // XLSXDATAVALIDATION_P_H 70 | -------------------------------------------------------------------------------- /src/xlsx/xlsxdocpropsapp_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 XLSXDOCPROPSAPP_H 26 | #define XLSXDOCPROPSAPP_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | #include "xlsxabstractooxmlfile.h" 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | class QIODevice; 47 | 48 | namespace QXlsx { 49 | 50 | class XLSX_AUTOTEST_EXPORT DocPropsApp : public AbstractOOXmlFile 51 | { 52 | public: 53 | DocPropsApp(CreateFlag flag); 54 | 55 | void addPartTitle(const QString &title); 56 | void addHeadingPair(const QString &name, int value); 57 | 58 | bool setProperty(const QString &name, const QString &value); 59 | QString property(const QString &name) const; 60 | QStringList propertyNames() const; 61 | 62 | void saveToXmlFile(QIODevice *device) const; 63 | bool loadFromXmlFile(QIODevice *device); 64 | 65 | private: 66 | QStringList m_titlesOfPartsList; 67 | QList > m_headingPairsList; 68 | QMap m_properties; 69 | }; 70 | 71 | } 72 | #endif // XLSXDOCPROPSAPP_H 73 | -------------------------------------------------------------------------------- /src/xlsx/xlsxdocpropscore_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 XLSXDOCPROPSCORE_H 26 | #define XLSXDOCPROPSCORE_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | #include "xlsxabstractooxmlfile.h" 41 | #include 42 | #include 43 | 44 | class QIODevice; 45 | 46 | namespace QXlsx { 47 | 48 | class XLSX_AUTOTEST_EXPORT DocPropsCore : public AbstractOOXmlFile 49 | { 50 | public: 51 | explicit DocPropsCore(CreateFlag flag); 52 | 53 | bool setProperty(const QString &name, const QString &value); 54 | QString property(const QString &name) const; 55 | QStringList propertyNames() const; 56 | 57 | void saveToXmlFile(QIODevice *device) const; 58 | bool loadFromXmlFile(QIODevice *device); 59 | 60 | private: 61 | QMap m_properties; 62 | }; 63 | 64 | } 65 | #endif // XLSXDOCPROPSCORE_H 66 | -------------------------------------------------------------------------------- /src/xlsx/xlsxdocument_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | 26 | #ifndef XLSXDOCUMENT_P_H 27 | #define XLSXDOCUMENT_P_H 28 | 29 | // 30 | // W A R N I N G 31 | // ------------- 32 | // 33 | // This file is not part of the Qt Xlsx API. It exists for the convenience 34 | // of the Qt Xlsx. This header file may change from 35 | // version to version without notice, or even be removed. 36 | // 37 | // We mean it. 38 | // 39 | 40 | #include "xlsxdocument.h" 41 | #include "xlsxworkbook.h" 42 | #include "xlsxcontenttypes_p.h" 43 | 44 | #include 45 | 46 | namespace QXlsx { 47 | 48 | class DocumentPrivate 49 | { 50 | Q_DECLARE_PUBLIC(Document) 51 | public: 52 | DocumentPrivate(Document *p); 53 | void init(); 54 | 55 | bool loadPackage(QIODevice *device); 56 | bool savePackage(QIODevice *device) const; 57 | 58 | Document *q_ptr; 59 | const QString defaultPackageName; //default name when package name not specified 60 | QString packageName; //name of the .xlsx file 61 | 62 | QMap documentProperties; //core, app and custom properties 63 | QSharedPointer workbook; 64 | QSharedPointer contentTypes; 65 | }; 66 | 67 | } 68 | 69 | #endif // XLSXDOCUMENT_P_H 70 | -------------------------------------------------------------------------------- /src/xlsx/xlsxdrawing.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | 26 | #include "xlsxdrawing_p.h" 27 | #include "xlsxdrawinganchor_p.h" 28 | #include "xlsxabstractsheet.h" 29 | 30 | #include 31 | #include 32 | #include 33 | 34 | namespace QXlsx { 35 | 36 | Drawing::Drawing(AbstractSheet *sheet, CreateFlag flag) 37 | :AbstractOOXmlFile(flag), sheet(sheet) 38 | { 39 | workbook = sheet->workbook(); 40 | } 41 | 42 | Drawing::~Drawing() 43 | { 44 | qDeleteAll(anchors); 45 | } 46 | 47 | void Drawing::saveToXmlFile(QIODevice *device) const 48 | { 49 | relationships()->clear(); 50 | 51 | QXmlStreamWriter writer(device); 52 | 53 | writer.writeStartDocument(QStringLiteral("1.0"), true); 54 | writer.writeStartElement(QStringLiteral("xdr:wsDr")); 55 | writer.writeAttribute(QStringLiteral("xmlns:xdr"), QStringLiteral("http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing")); 56 | writer.writeAttribute(QStringLiteral("xmlns:a"), QStringLiteral("http://schemas.openxmlformats.org/drawingml/2006/main")); 57 | 58 | foreach (DrawingAnchor *anchor, anchors) 59 | anchor->saveToXml(writer); 60 | 61 | writer.writeEndElement();//xdr:wsDr 62 | writer.writeEndDocument(); 63 | } 64 | 65 | bool Drawing::loadFromXmlFile(QIODevice *device) 66 | { 67 | QXmlStreamReader reader(device); 68 | while (!reader.atEnd()) { 69 | reader.readNextStartElement(); 70 | if (reader.tokenType() == QXmlStreamReader::StartElement) { 71 | if (reader.name() == QLatin1String("absoluteAnchor")) { 72 | DrawingAbsoluteAnchor * anchor = new DrawingAbsoluteAnchor(this); 73 | anchor->loadFromXml(reader); 74 | } else if (reader.name() == QLatin1String("oneCellAnchor")) { 75 | DrawingOneCellAnchor * anchor = new DrawingOneCellAnchor(this); 76 | anchor->loadFromXml(reader); 77 | } else if (reader.name() == QLatin1String("twoCellAnchor")) { 78 | DrawingTwoCellAnchor * anchor = new DrawingTwoCellAnchor(this); 79 | anchor->loadFromXml(reader); 80 | } 81 | } 82 | } 83 | 84 | return true; 85 | } 86 | 87 | } // namespace QXlsx 88 | -------------------------------------------------------------------------------- /src/xlsx/xlsxdrawing_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | 26 | #ifndef QXLSX_DRAWING_H 27 | #define QXLSX_DRAWING_H 28 | 29 | // 30 | // W A R N I N G 31 | // ------------- 32 | // 33 | // This file is not part of the Qt Xlsx API. It exists for the convenience 34 | // of the Qt Xlsx. This header file may change from 35 | // version to version without notice, or even be removed. 36 | // 37 | // We mean it. 38 | // 39 | 40 | #include "xlsxrelationships_p.h" 41 | #include "xlsxabstractooxmlfile.h" 42 | 43 | #include 44 | #include 45 | #include 46 | 47 | class QIODevice; 48 | class QXmlStreamWriter; 49 | 50 | namespace QXlsx { 51 | 52 | class DrawingAnchor; 53 | class Workbook; 54 | class AbstractSheet; 55 | class MediaFile; 56 | 57 | class Drawing : public AbstractOOXmlFile 58 | { 59 | public: 60 | Drawing(AbstractSheet *sheet, CreateFlag flag); 61 | ~Drawing(); 62 | void saveToXmlFile(QIODevice *device) const; 63 | bool loadFromXmlFile(QIODevice *device); 64 | 65 | AbstractSheet *sheet; 66 | Workbook *workbook; 67 | QList anchors; 68 | }; 69 | 70 | } // namespace QXlsx 71 | 72 | #endif // QXLSX_DRAWING_H 73 | -------------------------------------------------------------------------------- /src/xlsx/xlsxglobal.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 XLSXGLOBAL_H 26 | #define XLSXGLOBAL_H 27 | #include 28 | 29 | #define QT_BEGIN_NAMESPACE_XLSX namespace QXlsx { 30 | #define QT_END_NAMESPACE_XLSX } 31 | #define QTXLSX_USE_NAMESPACE using namespace QXlsx; 32 | 33 | #if !defined(QT_STATIC) && !defined(XLSX_NO_LIB) 34 | # if defined(QT_BUILD_XLSX_LIB) 35 | # define Q_XLSX_EXPORT Q_DECL_EXPORT 36 | # else 37 | # define Q_XLSX_EXPORT Q_DECL_IMPORT 38 | # endif 39 | #else 40 | # define Q_XLSX_EXPORT 41 | #endif 42 | 43 | #ifdef XLSX_TEST 44 | # define XLSX_AUTOTEST_EXPORT Q_XLSX_EXPORT 45 | #else 46 | # define XLSX_AUTOTEST_EXPORT 47 | #endif 48 | 49 | #endif // XLSXGLOBAL_H 50 | -------------------------------------------------------------------------------- /src/xlsx/xlsxmediafile.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | 26 | #include "xlsxmediafile_p.h" 27 | #include 28 | 29 | namespace QXlsx { 30 | 31 | MediaFile::MediaFile(const QByteArray &bytes, const QString &suffix, const QString &mimeType) 32 | : m_contents(bytes), m_suffix(suffix), m_mimeType(mimeType) 33 | , m_index(0), m_indexValid(false) 34 | { 35 | m_hashKey = QCryptographicHash::hash(m_contents, QCryptographicHash::Md5); 36 | } 37 | 38 | MediaFile::MediaFile(const QString &fileName) 39 | :m_fileName(fileName), m_index(0), m_indexValid(false) 40 | { 41 | 42 | } 43 | 44 | void MediaFile::set(const QByteArray &bytes, const QString &suffix, const QString &mimeType) 45 | { 46 | m_contents = bytes; 47 | m_suffix = suffix; 48 | m_mimeType = mimeType; 49 | m_hashKey = QCryptographicHash::hash(m_contents, QCryptographicHash::Md5); 50 | m_indexValid = false; 51 | } 52 | 53 | void MediaFile::setFileName(const QString &name) 54 | { 55 | m_fileName = name; 56 | } 57 | 58 | QString MediaFile::fileName() const 59 | { 60 | return m_fileName; 61 | } 62 | 63 | QString MediaFile::suffix() const 64 | { 65 | return m_suffix; 66 | } 67 | 68 | QString MediaFile::mimeType() const 69 | { 70 | return m_mimeType; 71 | } 72 | 73 | QByteArray MediaFile::contents() const 74 | { 75 | return m_contents; 76 | } 77 | 78 | int MediaFile::index() const 79 | { 80 | return m_index; 81 | } 82 | 83 | bool MediaFile::isIndexValid() const 84 | { 85 | return m_indexValid; 86 | } 87 | 88 | void MediaFile::setIndex(int idx) 89 | { 90 | m_index = idx; 91 | m_indexValid = true; 92 | } 93 | 94 | QByteArray MediaFile::hashKey() const 95 | { 96 | return m_hashKey; 97 | } 98 | 99 | } // namespace QXlsx 100 | -------------------------------------------------------------------------------- /src/xlsx/xlsxmediafile_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | 26 | #ifndef QXLSX_XLSXMEDIAFILE_H 27 | #define QXLSX_XLSXMEDIAFILE_H 28 | 29 | 30 | // 31 | // W A R N I N G 32 | // ------------- 33 | // 34 | // This file is not part of the Qt Xlsx API. It exists for the convenience 35 | // of the Qt Xlsx. This header file may change from 36 | // version to version without notice, or even be removed. 37 | // 38 | // We mean it. 39 | // 40 | 41 | #include "xlsxglobal.h" 42 | 43 | #include 44 | #include 45 | 46 | namespace QXlsx { 47 | 48 | class MediaFile 49 | { 50 | public: 51 | MediaFile(const QString &fileName); 52 | MediaFile(const QByteArray &bytes, const QString &suffix, const QString &mimeType=QString()); 53 | 54 | void set(const QByteArray &bytes, const QString &suffix, const QString &mimeType=QString()); 55 | QString suffix() const; 56 | QString mimeType() const; 57 | QByteArray contents() const; 58 | 59 | bool isIndexValid() const; 60 | int index() const; 61 | void setIndex(int idx); 62 | QByteArray hashKey() const; 63 | 64 | void setFileName(const QString &name); 65 | QString fileName() const; 66 | 67 | private: 68 | QString m_fileName; //... 69 | QByteArray m_contents; 70 | QString m_suffix; 71 | QString m_mimeType; 72 | 73 | int m_index; 74 | bool m_indexValid; 75 | QByteArray m_hashKey; 76 | }; 77 | 78 | } // namespace QXlsx 79 | 80 | #endif // QXLSX_XLSXMEDIAFILE_H 81 | -------------------------------------------------------------------------------- /src/xlsx/xlsxnumformatparser.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | #include "xlsxnumformatparser_p.h" 26 | 27 | #include 28 | 29 | namespace QXlsx { 30 | 31 | bool NumFormatParser::isDateTime(const QString &formatCode) 32 | { 33 | for (int i = 0; i < formatCode.length(); ++i) { 34 | const QChar &c = formatCode[i]; 35 | 36 | switch (c.unicode()) { 37 | case '[': 38 | // [h], [m], [s] are valid format for time 39 | if (i < formatCode.length()-2 && formatCode[i+2] == QLatin1Char(']')) { 40 | const QChar cc = formatCode[i+1].toLower(); 41 | if (cc == QLatin1Char('h') || cc == QLatin1Char('m') || cc == QLatin1Char('s')) 42 | return true; 43 | i+=2; 44 | break; 45 | } else { 46 | // condition or color: don't care, ignore 47 | while (i < formatCode.length() && formatCode[i] != QLatin1Char(']')) 48 | ++i; 49 | break; 50 | } 51 | 52 | // quoted plain text block: don't care, ignore 53 | case '"': 54 | while (i < formatCode.length()-1 && formatCode[++i] != QLatin1Char('"')) 55 | ; 56 | break; 57 | 58 | // escaped char: don't care, ignore 59 | case '\\': 60 | if (i < formatCode.length() - 1) 61 | ++i; 62 | break; 63 | 64 | // date/time can only be positive number, 65 | // so only the first section of the format make sense. 66 | case ';': 67 | return false; 68 | break; 69 | 70 | // days 71 | case 'D': 72 | case 'd': 73 | // years 74 | case 'Y': 75 | case 'y': 76 | // hours 77 | case 'H': 78 | case 'h': 79 | // seconds 80 | case 'S': 81 | case 's': 82 | // minutes or months, depending on context 83 | case 'M': 84 | case 'm': 85 | return true; 86 | 87 | default: 88 | break; 89 | } 90 | } 91 | return false; 92 | } 93 | 94 | } // namespace QXlsx 95 | -------------------------------------------------------------------------------- /src/xlsx/xlsxnumformatparser_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 QXLSX_NUMFORMATPARSER_H 26 | #define QXLSX_NUMFORMATPARSER_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | 41 | namespace QXlsx { 42 | 43 | class NumFormatParser 44 | { 45 | public: 46 | static bool isDateTime(const QString &formatCode); 47 | }; 48 | 49 | } // namespace QXlsx 50 | 51 | #endif // QXLSX_NUMFORMATPARSER_H 52 | -------------------------------------------------------------------------------- /src/xlsx/xlsxrelationships_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 XLSXRELATIONSHIPS_H 26 | #define XLSXRELATIONSHIPS_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | #include 41 | #include 42 | class QIODevice; 43 | 44 | namespace QXlsx { 45 | 46 | struct XlsxRelationship 47 | { 48 | QString id; 49 | QString type; 50 | QString target; 51 | QString targetMode; 52 | }; 53 | 54 | class XLSX_AUTOTEST_EXPORT Relationships 55 | { 56 | public: 57 | Relationships(); 58 | 59 | QList documentRelationships(const QString &relativeType) const; 60 | QList packageRelationships(const QString &relativeType) const; 61 | QList msPackageRelationships(const QString &relativeType) const; 62 | QList worksheetRelationships(const QString &relativeType) const; 63 | 64 | void addDocumentRelationship(const QString &relativeType, const QString &target); 65 | void addPackageRelationship(const QString &relativeType, const QString &target); 66 | void addMsPackageRelationship(const QString &relativeType, const QString &target); 67 | void addWorksheetRelationship(const QString &relativeType, const QString &target, const QString &targetMode=QString()); 68 | 69 | void saveToXmlFile(QIODevice *device) const; 70 | QByteArray saveToXmlData() const; 71 | bool loadFromXmlFile(QIODevice *device); 72 | bool loadFromXmlData(const QByteArray &data); 73 | XlsxRelationship getRelationshipById(const QString &id) const; 74 | 75 | void clear(); 76 | int count() const; 77 | bool isEmpty() const; 78 | 79 | private: 80 | QList relationships(const QString &type) const; 81 | void addRelationship(const QString &type, const QString &target, const QString &targetMode=QString()); 82 | 83 | QList m_relationships; 84 | }; 85 | 86 | } 87 | #endif // XLSXRELATIONSHIPS_H 88 | -------------------------------------------------------------------------------- /src/xlsx/xlsxrichstring.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 XLSXRICHSTRING_H 26 | #define XLSXRICHSTRING_H 27 | 28 | #include "xlsxglobal.h" 29 | #include "xlsxformat.h" 30 | #include 31 | #include 32 | #include 33 | 34 | QT_BEGIN_NAMESPACE_XLSX 35 | class RichStringPrivate; 36 | class RichString; 37 | // qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) 38 | Q_XLSX_EXPORT uint qHash(const RichString &rs, uint seed = 0) Q_DECL_NOTHROW; 39 | 40 | class Q_XLSX_EXPORT RichString 41 | { 42 | public: 43 | RichString(); 44 | explicit RichString(const QString text); 45 | RichString(const RichString &other); 46 | ~RichString(); 47 | 48 | bool isRichString() const; 49 | bool isNull() const; 50 | bool isEmtpy() const; 51 | QString toPlainString() const; 52 | QString toHtml() const; 53 | void setHtml(const QString &text); 54 | 55 | int fragmentCount() const; 56 | void addFragment(const QString &text, const Format &format); 57 | QString fragmentText(int index) const; 58 | Format fragmentFormat(int index) const; 59 | 60 | operator QVariant() const; 61 | 62 | RichString &operator=(const RichString &other); 63 | private: 64 | friend Q_XLSX_EXPORT uint qHash(const RichString &rs, uint seed) Q_DECL_NOTHROW; 65 | friend Q_XLSX_EXPORT bool operator==(const RichString &rs1, const RichString &rs2); 66 | friend Q_XLSX_EXPORT bool operator!=(const RichString &rs1, const RichString &rs2); 67 | friend Q_XLSX_EXPORT bool operator<(const RichString &rs1, const RichString &rs2); 68 | friend Q_XLSX_EXPORT QDebug operator<<(QDebug dbg, const RichString &rs); 69 | 70 | QSharedDataPointer d; 71 | }; 72 | 73 | Q_XLSX_EXPORT bool operator==(const RichString &rs1, const RichString &rs2); 74 | Q_XLSX_EXPORT bool operator!=(const RichString &rs1, const RichString &rs2); 75 | Q_XLSX_EXPORT bool operator<(const RichString &rs1, const RichString &rs2); 76 | Q_XLSX_EXPORT bool operator==(const RichString &rs1, const QString &rs2); 77 | Q_XLSX_EXPORT bool operator==(const QString &rs1, const RichString &rs2); 78 | Q_XLSX_EXPORT bool operator!=(const RichString &rs1, const QString &rs2); 79 | Q_XLSX_EXPORT bool operator!=(const QString &rs1, const RichString &rs2); 80 | 81 | #ifndef QT_NO_DEBUG_STREAM 82 | Q_XLSX_EXPORT QDebug operator<<(QDebug dbg, const RichString &rs); 83 | #endif 84 | 85 | QT_END_NAMESPACE_XLSX 86 | 87 | Q_DECLARE_METATYPE(QXlsx::RichString) 88 | 89 | #endif // XLSXRICHSTRING_H 90 | -------------------------------------------------------------------------------- /src/xlsx/xlsxrichstring_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 XLSXRICHSTRING_P_H 26 | #define XLSXRICHSTRING_P_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxrichstring.h" 40 | 41 | QT_BEGIN_NAMESPACE_XLSX 42 | 43 | class RichStringPrivate : public QSharedData 44 | { 45 | public: 46 | RichStringPrivate(); 47 | RichStringPrivate(const RichStringPrivate &other); 48 | ~RichStringPrivate(); 49 | 50 | QByteArray idKey() const; 51 | 52 | QStringList fragmentTexts; 53 | QList fragmentFormats; 54 | QByteArray _idKey; 55 | bool _dirty; 56 | }; 57 | 58 | QT_END_NAMESPACE_XLSX 59 | 60 | #endif // XLSXRICHSTRING_P_H 61 | -------------------------------------------------------------------------------- /src/xlsx/xlsxsharedstrings_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 XLSXSHAREDSTRINGS_H 26 | #define XLSXSHAREDSTRINGS_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | #include "xlsxrichstring.h" 41 | #include "xlsxabstractooxmlfile.h" 42 | #include 43 | #include 44 | #include 45 | 46 | class QIODevice; 47 | class QXmlStreamReader; 48 | class QXmlStreamWriter; 49 | 50 | namespace QXlsx { 51 | 52 | class XlsxSharedStringInfo 53 | { 54 | public: 55 | XlsxSharedStringInfo(int index=0, int count = 1) : 56 | index(index), count(count) 57 | { 58 | } 59 | 60 | int index; 61 | int count; 62 | }; 63 | 64 | class XLSX_AUTOTEST_EXPORT SharedStrings : public AbstractOOXmlFile 65 | { 66 | public: 67 | SharedStrings(CreateFlag flag); 68 | int count() const; 69 | bool isEmpty() const; 70 | 71 | int addSharedString(const QString &string); 72 | int addSharedString(const RichString &string); 73 | void removeSharedString(const QString &string); 74 | void removeSharedString(const RichString &string); 75 | void incRefByStringIndex(int idx); 76 | 77 | int getSharedStringIndex(const QString &string) const; 78 | int getSharedStringIndex(const RichString &string) const; 79 | RichString getSharedString(int index) const; 80 | QList getSharedStrings() const; 81 | 82 | void saveToXmlFile(QIODevice *device) const; 83 | bool loadFromXmlFile(QIODevice *device); 84 | 85 | private: 86 | void readString(QXmlStreamReader &reader); // 87 | void readRichStringPart(QXmlStreamReader &reader, RichString &rich); // 88 | void readPlainStringPart(QXmlStreamReader &reader, RichString &rich); // 89 | Format readRichStringPart_rPr(QXmlStreamReader &reader); 90 | void writeRichStringPart_rPr(QXmlStreamWriter &writer, const Format &format) const; 91 | 92 | QHash m_stringTable; //for fast lookup 93 | QList m_stringList; 94 | int m_stringCount; 95 | }; 96 | 97 | } 98 | #endif // XLSXSHAREDSTRINGS_H 99 | -------------------------------------------------------------------------------- /src/xlsx/xlsxsimpleooxmlfile.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | #include "xlsxsimpleooxmlfile_p.h" 26 | #include 27 | 28 | namespace QXlsx { 29 | SimpleOOXmlFile::SimpleOOXmlFile(CreateFlag flag) 30 | :AbstractOOXmlFile(flag) 31 | { 32 | } 33 | 34 | void SimpleOOXmlFile::saveToXmlFile(QIODevice *device) const 35 | { 36 | device->write(xmlData); 37 | } 38 | 39 | QByteArray SimpleOOXmlFile::saveToXmlData() const 40 | { 41 | return xmlData; 42 | } 43 | 44 | bool SimpleOOXmlFile::loadFromXmlData(const QByteArray &data) 45 | { 46 | xmlData = data; 47 | return true; 48 | } 49 | 50 | bool SimpleOOXmlFile::loadFromXmlFile(QIODevice *device) 51 | { 52 | xmlData = device->readAll(); 53 | return true; 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /src/xlsx/xlsxsimpleooxmlfile_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 XLSXSIMPLEOOXMLFILE_H 26 | #define XLSXSIMPLEOOXMLFILE_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | #include "xlsxabstractooxmlfile.h" 39 | 40 | #include 41 | class QIODevice; 42 | 43 | namespace QXlsx { 44 | 45 | class SimpleOOXmlFile : public AbstractOOXmlFile 46 | { 47 | public: 48 | SimpleOOXmlFile(CreateFlag flag); 49 | 50 | void saveToXmlFile(QIODevice *device) const; 51 | QByteArray saveToXmlData() const; 52 | bool loadFromXmlData(const QByteArray &data); 53 | bool loadFromXmlFile(QIODevice *device); 54 | 55 | QByteArray xmlData; 56 | }; 57 | 58 | } 59 | #endif // XLSXSIMPLEOOXMLFILE_H 60 | -------------------------------------------------------------------------------- /src/xlsx/xlsxtheme_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 XLSXTHEME_H 26 | #define XLSXTHEME_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | #include "xlsxabstractooxmlfile.h" 39 | 40 | #include 41 | class QIODevice; 42 | 43 | namespace QXlsx { 44 | 45 | class Theme : public AbstractOOXmlFile 46 | { 47 | public: 48 | Theme(CreateFlag flag); 49 | 50 | void saveToXmlFile(QIODevice *device) const; 51 | QByteArray saveToXmlData() const; 52 | bool loadFromXmlData(const QByteArray &data); 53 | bool loadFromXmlFile(QIODevice *device); 54 | 55 | QByteArray xmlData; 56 | }; 57 | 58 | } 59 | #endif // XLSXTHEME_H 60 | -------------------------------------------------------------------------------- /src/xlsx/xlsxutility_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 XLSXUTILITY_H 26 | #define XLSXUTILITY_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxglobal.h" 40 | class QPoint; 41 | class QString; 42 | class QStringList; 43 | class QColor; 44 | class QDateTime; 45 | class QTime; 46 | 47 | namespace QXlsx { 48 | class CellReference; 49 | 50 | XLSX_AUTOTEST_EXPORT bool parseXsdBoolean(const QString &value, bool defaultValue=false); 51 | 52 | XLSX_AUTOTEST_EXPORT QStringList splitPath(const QString &path); 53 | XLSX_AUTOTEST_EXPORT QString getRelFilePath(const QString &filePath); 54 | 55 | XLSX_AUTOTEST_EXPORT double datetimeToNumber(const QDateTime &dt, bool is1904=false); 56 | XLSX_AUTOTEST_EXPORT QDateTime datetimeFromNumber(double num, bool is1904=false); 57 | XLSX_AUTOTEST_EXPORT double timeToNumber(const QTime &t); 58 | 59 | XLSX_AUTOTEST_EXPORT QString createSafeSheetName(const QString &nameProposal); 60 | XLSX_AUTOTEST_EXPORT QString escapeSheetName(const QString &sheetName); 61 | XLSX_AUTOTEST_EXPORT QString unescapeSheetName(const QString &sheetName); 62 | 63 | XLSX_AUTOTEST_EXPORT bool isSpaceReserveNeeded(const QString &string); 64 | 65 | XLSX_AUTOTEST_EXPORT QString convertSharedFormula(const QString &rootFormula, const CellReference &rootCell, const CellReference &cell); 66 | 67 | } //QXlsx 68 | #endif // XLSXUTILITY_H 69 | -------------------------------------------------------------------------------- /src/xlsx/xlsxworkbook_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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_P_H 26 | #define XLSXWORKBOOK_P_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include "xlsxworkbook.h" 40 | #include "xlsxabstractooxmlfile_p.h" 41 | #include "xlsxtheme_p.h" 42 | #include "xlsxsimpleooxmlfile_p.h" 43 | #include "xlsxrelationships_p.h" 44 | 45 | #include 46 | #include 47 | #include 48 | 49 | namespace QXlsx { 50 | 51 | struct XlsxDefineNameData 52 | { 53 | XlsxDefineNameData() 54 | :sheetId(-1) 55 | {} 56 | XlsxDefineNameData(const QString &name, const QString &formula, const QString &comment, int sheetId=-1) 57 | :name(name), formula(formula), comment(comment), sheetId(sheetId) 58 | { 59 | 60 | } 61 | QString name; 62 | QString formula; 63 | QString comment; 64 | //using internal sheetId, instead of the localSheetId(order in the workbook) 65 | int sheetId; 66 | }; 67 | 68 | class WorkbookPrivate : public AbstractOOXmlFilePrivate 69 | { 70 | Q_DECLARE_PUBLIC(Workbook) 71 | public: 72 | WorkbookPrivate(Workbook *q, Workbook::CreateFlag flag); 73 | 74 | QSharedPointer sharedStrings; 75 | QList > sheets; 76 | QList > externalLinks; 77 | QStringList sheetNames; 78 | QSharedPointer styles; 79 | QSharedPointer theme; 80 | QList > mediaFiles; 81 | QList > chartFiles; 82 | QList definedNamesList; 83 | 84 | bool strings_to_numbers_enabled; 85 | bool strings_to_hyperlinks_enabled; 86 | bool html_to_richstring_enabled; 87 | bool date1904; 88 | QString defaultDateFormat; 89 | 90 | int x_window; 91 | int y_window; 92 | int window_width; 93 | int window_height; 94 | 95 | int activesheetIndex; 96 | int firstsheet; 97 | int table_count; 98 | 99 | //Used to generate new sheet name and id 100 | int last_worksheet_index; 101 | int last_chartsheet_index; 102 | int last_sheet_id; 103 | }; 104 | 105 | } 106 | 107 | #endif // XLSXWORKBOOK_P_H 108 | -------------------------------------------------------------------------------- /src/xlsx/xlsxzipreader.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | 26 | #include "xlsxzipreader_p.h" 27 | 28 | #include 29 | 30 | namespace QXlsx { 31 | 32 | ZipReader::ZipReader(const QString &filePath) : 33 | m_reader(new QZipReader(filePath)) 34 | { 35 | init(); 36 | } 37 | 38 | ZipReader::ZipReader(QIODevice *device) : 39 | m_reader(new QZipReader(device)) 40 | { 41 | init(); 42 | } 43 | 44 | ZipReader::~ZipReader() 45 | { 46 | 47 | } 48 | 49 | void ZipReader::init() 50 | { 51 | #if QT_VERSION >= 0x050600 52 | QVector allFiles = m_reader->fileInfoList(); 53 | #else 54 | QList allFiles = m_reader->fileInfoList(); 55 | #endif 56 | foreach (const QZipReader::FileInfo &fi, allFiles) { 57 | if (fi.isFile) 58 | m_filePaths.append(fi.filePath); 59 | } 60 | } 61 | 62 | bool ZipReader::exists() const 63 | { 64 | return m_reader->exists(); 65 | } 66 | 67 | QStringList ZipReader::filePaths() const 68 | { 69 | return m_filePaths; 70 | } 71 | 72 | QByteArray ZipReader::fileData(const QString &fileName) const 73 | { 74 | return m_reader->fileData(fileName); 75 | } 76 | 77 | } // namespace QXlsx 78 | -------------------------------------------------------------------------------- /src/xlsx/xlsxzipreader_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | 26 | #ifndef QXLSX_XLSXZIPREADER_P_H 27 | #define QXLSX_XLSXZIPREADER_P_H 28 | 29 | // 30 | // W A R N I N G 31 | // ------------- 32 | // 33 | // This file is not part of the Qt Xlsx API. It exists for the convenience 34 | // of the Qt Xlsx. This header file may change from 35 | // version to version without notice, or even be removed. 36 | // 37 | // We mean it. 38 | // 39 | 40 | #include "xlsxglobal.h" 41 | #include 42 | #include 43 | #if QT_VERSION >= 0x050600 44 | #include 45 | #endif 46 | class QZipReader; 47 | class QIODevice; 48 | 49 | namespace QXlsx { 50 | 51 | class XLSX_AUTOTEST_EXPORT ZipReader 52 | { 53 | public: 54 | explicit ZipReader(const QString &fileName); 55 | explicit ZipReader(QIODevice *device); 56 | ~ZipReader(); 57 | bool exists() const; 58 | QStringList filePaths() const; 59 | QByteArray fileData(const QString &fileName) const; 60 | 61 | private: 62 | Q_DISABLE_COPY(ZipReader) 63 | void init(); 64 | QScopedPointer m_reader; 65 | QStringList m_filePaths; 66 | }; 67 | 68 | } // namespace QXlsx 69 | 70 | #endif // QXLSX_XLSXZIPREADER_P_H 71 | -------------------------------------------------------------------------------- /src/xlsx/xlsxzipwriter.cpp: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 | #include "xlsxzipwriter_p.h" 26 | #include 27 | #include 28 | 29 | namespace QXlsx { 30 | 31 | ZipWriter::ZipWriter(const QString &filePath) 32 | { 33 | m_writer = new QZipWriter(filePath, QIODevice::WriteOnly); 34 | m_writer->setCompressionPolicy(QZipWriter::AutoCompress); 35 | } 36 | 37 | ZipWriter::ZipWriter(QIODevice *device) 38 | { 39 | m_writer = new QZipWriter(device); 40 | m_writer->setCompressionPolicy(QZipWriter::AutoCompress); 41 | } 42 | 43 | ZipWriter::~ZipWriter() 44 | { 45 | delete m_writer; 46 | } 47 | 48 | bool ZipWriter::error() const 49 | { 50 | return m_writer->status() != QZipWriter::NoError; 51 | } 52 | 53 | void ZipWriter::addFile(const QString &filePath, QIODevice *device) 54 | { 55 | m_writer->addFile(filePath, device); 56 | } 57 | 58 | void ZipWriter::addFile(const QString &filePath, const QByteArray &data) 59 | { 60 | m_writer->addFile(filePath, data); 61 | } 62 | 63 | void ZipWriter::close() 64 | { 65 | m_writer->close(); 66 | } 67 | 68 | } // namespace QXlsx 69 | -------------------------------------------------------------------------------- /src/xlsx/xlsxzipwriter_p.h: -------------------------------------------------------------------------------- 1 | /**************************************************************************** 2 | ** Copyright (c) 2013-2014 Debao Zhang 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 QXLSX_ZIPWRITER_H 26 | #define QXLSX_ZIPWRITER_H 27 | 28 | // 29 | // W A R N I N G 30 | // ------------- 31 | // 32 | // This file is not part of the Qt Xlsx API. It exists for the convenience 33 | // of the Qt Xlsx. This header file may change from 34 | // version to version without notice, or even be removed. 35 | // 36 | // We mean it. 37 | // 38 | 39 | #include 40 | class QIODevice; 41 | class QZipWriter; 42 | 43 | namespace QXlsx { 44 | 45 | class ZipWriter 46 | { 47 | public: 48 | explicit ZipWriter(const QString &filePath); 49 | explicit ZipWriter(QIODevice *device); 50 | ~ZipWriter(); 51 | 52 | void addFile(const QString &filePath, QIODevice *device); 53 | void addFile(const QString &filePath, const QByteArray &data); 54 | bool error() const; 55 | void close(); 56 | 57 | private: 58 | QZipWriter *m_writer; 59 | }; 60 | 61 | } // namespace QXlsx 62 | 63 | #endif // QXLSX_ZIPWRITER_H 64 | -------------------------------------------------------------------------------- /sync.profile: -------------------------------------------------------------------------------- 1 | %modules = ( 2 | "QtXlsx" => "$basedir/src/xlsx", 3 | ); 4 | 5 | %dependencies = ( 6 | "qtbase" => "", 7 | ); 8 | -------------------------------------------------------------------------------- /tests/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # 2 | # create a test-enabled library before creating tests 3 | # themselves (export more functions than regular DLL) 4 | # 5 | 6 | # Create a fake private/ include folder 7 | # in the compilation tree to allow the 8 | # #include "private/..." instruction to 9 | # work 10 | set( 11 | QtXlsxWriter_PRIVATE_SOURCE_FILES 12 | ${CMAKE_CURRENT_BINARY_DIR}/include) 13 | 14 | if(DEBUG) 15 | message("Private include directory : ${QtXlsxWriter_PRIVATE_SOURCE_FILES}") 16 | endif() 17 | file(MAKE_DIRECTORY "${QtXlsxWriter_PRIVATE_SOURCE_FILES}/private") 18 | 19 | # Copy all private includes in the created folder 20 | file(GLOB private_includes ${CMAKE_CURRENT_SOURCE_DIR}/../src/xlsx/*_p.h) 21 | foreach(private_include ${private_includes}) 22 | if(DEBUG) 23 | message("Copying private include : ${private_include}") 24 | endif() 25 | file(COPY ${private_include} DESTINATION ${QtXlsxWriter_PRIVATE_SOURCE_FILES}/private) 26 | endforeach() 27 | 28 | set(CMAKE_AUTOMOC ON) 29 | 30 | file( 31 | GLOB 32 | QtXlsxWriterTest_SOURCE_FILES 33 | ${CMAKE_CURRENT_SOURCE_DIR}/../src/xlsx/*.cpp 34 | ${CMAKE_CURRENT_BINARY_DIR}/QtXlsxWriter_automoc.cpp 35 | ) 36 | 37 | include_directories( 38 | ${CMAKE_CURRENT_BINARY_DIR} 39 | ${Qt5Core_INCLUDE_DIRS} 40 | ${Qt5Gui_INCLUDE_DIRS} 41 | ${Qt5Gui_PRIVATE_INCLUDE_DIRS} 42 | ) 43 | 44 | add_definitions(-DQT_BUILD_XLSX_LIB) 45 | add_definitions(-DXLSX_TEST) 46 | add_library(QtXlsxWriterTest SHARED "${QtXlsxWriterTest_SOURCE_FILES}") 47 | 48 | # automatically add C++11 support with GCC 49 | if(NOT MSVC) 50 | target_compile_features(QtXlsxWriterTest PRIVATE cxx_range_for) 51 | endif() 52 | 53 | 54 | set_target_properties(QtXlsxWriterTest PROPERTIES DEBUG_POSTFIX "d") 55 | 56 | target_link_libraries(QtXlsxWriterTest ${Qt5Core_LIBRARIES}) 57 | target_link_libraries(QtXlsxWriterTest ${Qt5Gui_LIBRARIES}) 58 | 59 | add_custom_command(TARGET QtXlsxWriterTest POST_BUILD 60 | COMMAND ${CMAKE_COMMAND} 61 | -E copy_directory $ auto/$) 62 | 63 | add_subdirectory(auto) 64 | -------------------------------------------------------------------------------- /tests/auto/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | set(TESTS 2 | cellreference 3 | document 4 | format 5 | propsapp 6 | propscore 7 | relationships 8 | richstring 9 | sharedstrings 10 | styles 11 | utility 12 | worksheet 13 | xlsxconditionalformatting 14 | zipreader) 15 | 16 | enable_testing() 17 | 18 | # Compile each defined test and 19 | # declare it for ctest tool 20 | foreach(test IN ITEMS ${TESTS}) 21 | if(DEBUG) 22 | message("configure test '${test}'") 23 | endif() 24 | file( GLOB TEST_SRC ${test}/*.cpp) 25 | include_directories( 26 | ${CMAKE_CURRENT_SOURCE_DIR}/../../src/xlsx/ 27 | ${Qt5Core_INCLUDE_DIRS} 28 | ${Qt5Gui_INCLUDE_DIRS} 29 | ${QtXlsxWriter_PRIVATE_SOURCE_FILES} 30 | ${CMAKE_CURRENT_BINARY_DIR} # .moc files 31 | ) 32 | 33 | add_definitions(-DXLSX_TEST) 34 | remove_definitions(-DQT_BUILD_XLSX_LIB) 35 | 36 | add_executable(${test}_testDriver ${TEST_SRC} ) 37 | 38 | # automatically add C++11 support with GCC 39 | if(NOT MSVC) 40 | target_compile_features(${test}_testDriver PRIVATE cxx_range_for) 41 | endif() 42 | 43 | 44 | target_link_libraries(${test}_testDriver ${Qt5Core_LIBRARIES}) 45 | target_link_libraries(${test}_testDriver ${Qt5Gui_LIBRARIES}) 46 | target_link_libraries(${test}_testDriver ${Qt5Test_LIBRARIES}) 47 | target_link_libraries(${test}_testDriver QtXlsxWriterTest) 48 | 49 | add_test(NAME ${test} COMMAND ${test}_testDriver) 50 | 51 | endforeach(test) 52 | -------------------------------------------------------------------------------- /tests/auto/auto.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE=subdirs 2 | SUBDIRS=\ 3 | utility \ 4 | worksheet \ 5 | zipreader \ 6 | relationships \ 7 | propscore \ 8 | propsapp \ 9 | document \ 10 | sharedstrings \ 11 | styles \ 12 | format \ 13 | richstring \ 14 | xlsxconditionalformatting \ 15 | cellreference \ 16 | cmake 17 | -------------------------------------------------------------------------------- /tests/auto/cellreference/cellreference.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2013-08-30T11:16:26 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += testlib xlsx #xlsx-private 8 | CONFIG += testcase 9 | DEFINES += XLSX_TEST 10 | 11 | TARGET = tst_cellreferencetest 12 | CONFIG += console 13 | CONFIG -= app_bundle 14 | 15 | TEMPLATE = app 16 | 17 | 18 | SOURCES += tst_cellreferencetest.cpp 19 | DEFINES += SRCDIR=\\\"$$PWD/\\\" 20 | -------------------------------------------------------------------------------- /tests/auto/cellreference/tst_cellreferencetest.cpp: -------------------------------------------------------------------------------- 1 | #include "xlsxcellreference.h" 2 | #include 3 | #include 4 | 5 | using namespace QXlsx; 6 | 7 | class CellReferenceTest : public QObject 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | CellReferenceTest(); 13 | 14 | private Q_SLOTS: 15 | void test_toString_data(); 16 | void test_toString(); 17 | void test_fromString_data(); 18 | void test_fromString(); 19 | }; 20 | 21 | CellReferenceTest::CellReferenceTest() 22 | { 23 | } 24 | 25 | void CellReferenceTest::test_fromString() 26 | { 27 | QFETCH(QString, cell); 28 | QFETCH(int, row); 29 | QFETCH(int, col); 30 | CellReference pos(cell); 31 | QCOMPARE(pos.row(), row); 32 | QCOMPARE(pos.column(), col); 33 | } 34 | 35 | void CellReferenceTest::test_fromString_data() 36 | { 37 | QTest::addColumn("cell"); 38 | QTest::addColumn("row"); 39 | QTest::addColumn("col"); 40 | 41 | QTest::newRow("A1") << "A1" << 1 << 1; 42 | QTest::newRow("B1") << "B1" << 1 << 2; 43 | QTest::newRow("C1") << "C1" << 1 << 3; 44 | QTest::newRow("J1") << "J1" << 1 << 10; 45 | QTest::newRow("A2") << "A2" << 2 << 1; 46 | QTest::newRow("A3") << "A3" << 3 << 1; 47 | QTest::newRow("A10") << "$A10" << 10 << 1; 48 | QTest::newRow("Z8") << "Z$8" << 8 << 26; 49 | QTest::newRow("AA10") << "$AA$10" << 10 << 27; 50 | QTest::newRow("IU2") << "IU2" << 2 << 255; 51 | QTest::newRow("XFD1") << "XFD1" << 1 << 16384; 52 | QTest::newRow("XFE1048577") << "XFE1048577" << 1048577 << 16385; 53 | } 54 | 55 | void CellReferenceTest::test_toString() 56 | { 57 | QFETCH(int, row); 58 | QFETCH(int, col); 59 | QFETCH(bool, row_abs); 60 | QFETCH(bool, col_abs); 61 | QFETCH(QString, cell); 62 | 63 | QCOMPARE(CellReference(row,col).toString(row_abs, col_abs), cell); 64 | } 65 | 66 | void CellReferenceTest::test_toString_data() 67 | { 68 | QTest::addColumn("row"); 69 | QTest::addColumn("col"); 70 | QTest::addColumn("row_abs"); 71 | QTest::addColumn("col_abs"); 72 | QTest::addColumn("cell"); 73 | 74 | QTest::newRow("simple") << 1 << 1 << false << false << "A1"; 75 | QTest::newRow("rowabs") << 1 << 1 << true << false << "A$1"; 76 | QTest::newRow("colabs") << 1 << 1 << false << true << "$A1"; 77 | QTest::newRow("bothabs") << 1 << 1 << true << true << "$A$1"; 78 | QTest::newRow("...") << 1048577 << 16385 << false << false << "XFE1048577"; 79 | } 80 | 81 | QTEST_APPLESS_MAIN(CellReferenceTest) 82 | 83 | #include "tst_cellreferencetest.moc" 84 | -------------------------------------------------------------------------------- /tests/auto/cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | 2 | cmake_minimum_required(VERSION 2.8) 3 | 4 | project(qmake_cmake_files) 5 | 6 | enable_testing() 7 | 8 | add_test(dummy ${CMAKE_COMMAND} -E echo) 9 | 10 | -------------------------------------------------------------------------------- /tests/auto/cmake/cmake.pro: -------------------------------------------------------------------------------- 1 | 2 | # Cause make to do nothing. 3 | TEMPLATE = subdirs 4 | 5 | CMAKE_QT_MODULES_UNDER_TEST = xlsx 6 | 7 | CONFIG += ctest_testcase 8 | -------------------------------------------------------------------------------- /tests/auto/document/document.pro: -------------------------------------------------------------------------------- 1 | QT += testlib xlsx # xlsx-private 2 | CONFIG += testcase 3 | DEFINES += XLSX_TEST 4 | 5 | TARGET = tst_document 6 | CONFIG += console 7 | CONFIG -= app_bundle 8 | 9 | TEMPLATE = app 10 | 11 | 12 | SOURCES += tst_documenttest.cpp 13 | DEFINES += SRCDIR=\\\"$$PWD/\\\" 14 | -------------------------------------------------------------------------------- /tests/auto/format/format.pro: -------------------------------------------------------------------------------- 1 | QT += testlib xlsx # xlsx-private 2 | CONFIG += testcase 3 | DEFINES += XLSX_TEST 4 | 5 | TARGET = tst_format 6 | CONFIG += console 7 | CONFIG -= app_bundle 8 | 9 | TEMPLATE = app 10 | 11 | SOURCES += tst_formattest.cpp 12 | DEFINES += SRCDIR=\\\"$$PWD/\\\" 13 | -------------------------------------------------------------------------------- /tests/auto/format/tst_formattest.cpp: -------------------------------------------------------------------------------- 1 | #include "xlsxformat.h" 2 | #include 3 | #include 4 | 5 | QTXLSX_USE_NAMESPACE 6 | 7 | class FormatTest : public QObject 8 | { 9 | Q_OBJECT 10 | 11 | public: 12 | FormatTest(); 13 | 14 | private Q_SLOTS: 15 | void testDateTimeFormat(); 16 | void testDateTimeFormat_data(); 17 | }; 18 | 19 | FormatTest::FormatTest() 20 | { 21 | } 22 | 23 | void FormatTest::testDateTimeFormat() 24 | { 25 | QFETCH(QString, data); 26 | QFETCH(bool, res); 27 | 28 | Format fmt; 29 | fmt.setNumberFormat(data); 30 | 31 | QCOMPARE(fmt.isDateTimeFormat(), res); 32 | } 33 | 34 | void FormatTest::testDateTimeFormat_data() 35 | { 36 | QTest::addColumn("data"); 37 | QTest::addColumn("res"); 38 | 39 | QTest::newRow("0") << QString("yyyy-mm-dd")< 3 | #include 4 | 5 | class DocPropsAppTest : public QObject 6 | { 7 | Q_OBJECT 8 | 9 | public: 10 | DocPropsAppTest(); 11 | 12 | private Q_SLOTS: 13 | void testCase1(); 14 | }; 15 | 16 | DocPropsAppTest::DocPropsAppTest() 17 | { 18 | 19 | } 20 | 21 | void DocPropsAppTest::testCase1() 22 | { 23 | QXlsx::DocPropsApp props(QXlsx::DocPropsApp::F_NewFromScratch); 24 | 25 | props.setProperty("company", "HMI CN"); 26 | props.setProperty("manager", "Debao"); 27 | 28 | QFile f1("temp.xml"); 29 | f1.open(QFile::WriteOnly); 30 | props.saveToXmlFile(&f1); 31 | f1.close(); 32 | 33 | f1.open(QFile::ReadOnly); 34 | QXlsx::DocPropsApp props2(QXlsx::DocPropsApp::F_LoadFromExists); 35 | props2.loadFromXmlFile(&f1); 36 | 37 | QCOMPARE(props2.property("company"), QString("HMI CN")); 38 | QCOMPARE(props2.property("manager"), QString("Debao")); 39 | QFile::remove("temp.xml"); 40 | } 41 | 42 | QTEST_APPLESS_MAIN(DocPropsAppTest) 43 | 44 | #include "tst_docpropsapptest.moc" 45 | -------------------------------------------------------------------------------- /tests/auto/propscore/propscore.pro: -------------------------------------------------------------------------------- 1 | QT += testlib xlsx xlsx-private 2 | CONFIG += testcase 3 | DEFINES += XLSX_TEST 4 | 5 | TARGET = tst_propscoretest 6 | CONFIG += console 7 | CONFIG -= app_bundle 8 | 9 | TEMPLATE = app 10 | 11 | 12 | SOURCES += tst_propscoretest.cpp 13 | DEFINES += SRCDIR=\\\"$$PWD/\\\" 14 | -------------------------------------------------------------------------------- /tests/auto/propscore/tst_propscoretest.cpp: -------------------------------------------------------------------------------- 1 | #include "private/xlsxdocpropscore_p.h" 2 | #include 3 | #include 4 | #include 5 | 6 | class DocPropsCoreTest : public QObject 7 | { 8 | Q_OBJECT 9 | 10 | public: 11 | DocPropsCoreTest(); 12 | 13 | private Q_SLOTS: 14 | void testCase1(); 15 | }; 16 | 17 | DocPropsCoreTest::DocPropsCoreTest() 18 | { 19 | } 20 | 21 | void DocPropsCoreTest::testCase1() 22 | { 23 | QXlsx::DocPropsCore props(QXlsx::DocPropsCore::F_NewFromScratch); 24 | 25 | props.setProperty("creator", "Debao"); 26 | props.setProperty("keywords", "Test, test, TEST"); 27 | props.setProperty("title", "ABC"); 28 | 29 | QFile f1("temp.xml"); 30 | f1.open(QFile::WriteOnly); 31 | props.saveToXmlFile(&f1); 32 | f1.close(); 33 | 34 | f1.open(QFile::ReadOnly); 35 | QXlsx::DocPropsCore props2(QXlsx::DocPropsCore::F_LoadFromExists); 36 | props2.loadFromXmlFile(&f1); 37 | 38 | QCOMPARE(props2.property("creator"), QString("Debao")); 39 | QCOMPARE(props2.property("keywords"), QString("Test, test, TEST")); 40 | QCOMPARE(props2.property("title"), QString("ABC")); 41 | QFile::remove("temp.xml"); 42 | } 43 | 44 | QTEST_APPLESS_MAIN(DocPropsCoreTest) 45 | 46 | #include "tst_propscoretest.moc" 47 | -------------------------------------------------------------------------------- /tests/auto/relationships/relationships.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2013-09-10T13:27:11 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += testlib xlsx xlsx-private 8 | CONFIG += testcase 9 | DEFINES += XLSX_TEST 10 | 11 | TARGET = tst_relationshipstest 12 | CONFIG += console 13 | CONFIG -= app_bundle 14 | 15 | TEMPLATE = app 16 | 17 | 18 | SOURCES += tst_relationshipstest.cpp 19 | DEFINES += SRCDIR=\\\"$$PWD/\\\" 20 | -------------------------------------------------------------------------------- /tests/auto/relationships/tst_relationshipstest.cpp: -------------------------------------------------------------------------------- 1 | #include "private/xlsxrelationships_p.h" 2 | #include 3 | #include 4 | 5 | class RelationshipsTest : public QObject 6 | { 7 | Q_OBJECT 8 | 9 | public: 10 | RelationshipsTest(); 11 | 12 | private Q_SLOTS: 13 | void testSaveXml(); 14 | void testLoadXml(); 15 | }; 16 | 17 | RelationshipsTest::RelationshipsTest() 18 | { 19 | 20 | } 21 | 22 | void RelationshipsTest::testSaveXml() 23 | { 24 | QXlsx::Relationships rels; 25 | rels.addDocumentRelationship("/officeDocument", "xl/workbook.xml"); 26 | 27 | QByteArray xmldata = rels.saveToXmlData(); 28 | 29 | QVERIFY2(xmldata.contains(""), ""); 30 | } 31 | 32 | void RelationshipsTest::testLoadXml() 33 | { 34 | QByteArray xmldata("<\?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"\?>" 35 | "" 36 | "" 37 | ""); 38 | 39 | QXlsx::Relationships rels; 40 | rels.loadFromXmlData(xmldata); 41 | 42 | QCOMPARE(rels.documentRelationships("/officeDocument").size(), 1); 43 | } 44 | 45 | QTEST_APPLESS_MAIN(RelationshipsTest) 46 | 47 | #include "tst_relationshipstest.moc" 48 | -------------------------------------------------------------------------------- /tests/auto/richstring/richstring.pro: -------------------------------------------------------------------------------- 1 | QT += testlib xlsx xlsx-private 2 | CONFIG += testcase 3 | DEFINES += XLSX_TEST 4 | 5 | TARGET = tst_richstringtest 6 | CONFIG += console 7 | CONFIG -= app_bundle 8 | 9 | TEMPLATE = app 10 | 11 | SOURCES += tst_richstringtest.cpp 12 | DEFINES += SRCDIR=\\\"$$PWD/\\\" 13 | -------------------------------------------------------------------------------- /tests/auto/richstring/tst_richstringtest.cpp: -------------------------------------------------------------------------------- 1 | #include "xlsxrichstring.h" 2 | #include 3 | #include 4 | 5 | class RichstringTest : public QObject 6 | { 7 | Q_OBJECT 8 | 9 | public: 10 | RichstringTest(); 11 | 12 | private Q_SLOTS: 13 | void testEqual(); 14 | }; 15 | 16 | RichstringTest::RichstringTest() 17 | { 18 | } 19 | 20 | void RichstringTest::testEqual() 21 | { 22 | QXlsx::RichString rs; 23 | rs.addFragment("Hello", QXlsx::Format()); 24 | rs.addFragment(" RichText", QXlsx::Format()); 25 | 26 | QXlsx::RichString rs2; 27 | rs2.addFragment("Hello", QXlsx::Format()); 28 | rs2.addFragment(" Qt!", QXlsx::Format()); 29 | 30 | QXlsx::RichString rs3; 31 | rs3.addFragment("Hello", QXlsx::Format()); 32 | rs3.addFragment(" Qt!", QXlsx::Format()); 33 | 34 | QVERIFY2(rs2 != rs, "Failure"); 35 | QVERIFY2(rs2 == rs3, "Failure"); 36 | QVERIFY2(rs2 != QStringLiteral("Hello Qt!"), "Failure"); 37 | } 38 | 39 | QTEST_APPLESS_MAIN(RichstringTest) 40 | 41 | #include "tst_richstringtest.moc" 42 | -------------------------------------------------------------------------------- /tests/auto/sharedstrings/sharedstrings.pro: -------------------------------------------------------------------------------- 1 | QT += testlib xlsx xlsx-private 2 | CONFIG += testcase 3 | DEFINES += XLSX_TEST 4 | 5 | TARGET = tst_sharedstringstest 6 | CONFIG += console 7 | CONFIG -= app_bundle 8 | 9 | TEMPLATE = app 10 | 11 | 12 | SOURCES += tst_sharedstringstest.cpp 13 | DEFINES += SRCDIR=\\\"$$PWD/\\\" 14 | -------------------------------------------------------------------------------- /tests/auto/styles/styles.pro: -------------------------------------------------------------------------------- 1 | QT += testlib xlsx xlsx-private 2 | CONFIG += testcase 3 | DEFINES += XLSX_TEST 4 | 5 | TARGET = tst_stylestest 6 | CONFIG += console 7 | CONFIG -= app_bundle 8 | 9 | TEMPLATE = app 10 | 11 | 12 | SOURCES += tst_stylestest.cpp 13 | DEFINES += SRCDIR=\\\"$$PWD/\\\" 14 | -------------------------------------------------------------------------------- /tests/auto/utility/utility.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2013-08-30T11:16:26 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += testlib xlsx xlsx-private 8 | CONFIG += testcase 9 | DEFINES += XLSX_TEST 10 | 11 | TARGET = tst_utilitytest 12 | CONFIG += console 13 | CONFIG -= app_bundle 14 | 15 | TEMPLATE = app 16 | 17 | SOURCES += tst_utilitytest.cpp 18 | DEFINES += SRCDIR=\\\"$$PWD/\\\" 19 | -------------------------------------------------------------------------------- /tests/auto/worksheet/worksheet.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2013-09-06T10:52:56 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += testlib xlsx xlsx-private 8 | CONFIG += testcase 9 | DEFINES += XLSX_TEST 10 | 11 | TARGET = tst_worksheet 12 | CONFIG += console 13 | CONFIG -= app_bundle 14 | 15 | TEMPLATE = app 16 | 17 | SOURCES += tst_worksheet.cpp 18 | DEFINES += SRCDIR=\\\"$$PWD/\\\" 19 | -------------------------------------------------------------------------------- /tests/auto/xlsxconditionalformatting/tst_conditionalformattingtest.cpp: -------------------------------------------------------------------------------- 1 | #include "xlsxconditionalformatting.h" 2 | #include "xlsxformat.h" 3 | #include "private/xlsxconditionalformatting_p.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | using namespace QXlsx; 11 | 12 | class ConditionalFormattingTest : public QObject 13 | { 14 | Q_OBJECT 15 | 16 | public: 17 | ConditionalFormattingTest(); 18 | 19 | private Q_SLOTS: 20 | void testHighlightRules(); 21 | void testHighlightRules_data(); 22 | void testDataBarRules(); 23 | }; 24 | 25 | ConditionalFormattingTest::ConditionalFormattingTest() 26 | { 27 | } 28 | 29 | void ConditionalFormattingTest::testHighlightRules_data() 30 | { 31 | QTest::addColumn("type"); 32 | QTest::addColumn("formula1"); 33 | QTest::addColumn("formula2"); 34 | QTest::addColumn("result"); 35 | 36 | QTest::newRow("lessThan")<<(int)ConditionalFormatting::Highlight_LessThan 37 | <<"100" 38 | <100"); 40 | QTest::newRow("between")<<(int)ConditionalFormatting::Highlight_Between 41 | <<"4" 42 | <<"20" 43 | <420"); 44 | 45 | QTest::newRow("containsText")<<(int)ConditionalFormatting::Highlight_ContainsText 46 | <<"Qt" 47 | <"); 49 | QTest::newRow("beginsWith")<<(int)ConditionalFormatting::Highlight_BeginsWith 50 | <<"Qt" 51 | <LEFT(C3,LEN"); //(\"Qt\"))=\"Qt\""); 53 | QTest::newRow("duplicateValues")<<(int)ConditionalFormatting::Highlight_Duplicate 54 | <"); 57 | } 58 | 59 | void ConditionalFormattingTest::testHighlightRules() 60 | { 61 | QFETCH(int, type); 62 | QFETCH(QString, formula1); 63 | QFETCH(QString, formula2); 64 | QFETCH(QByteArray, result); 65 | 66 | Format fmt; 67 | fmt.setFontBold(true); 68 | fmt.setDxfIndex(0); 69 | 70 | ConditionalFormatting cf; 71 | cf.addHighlightCellsRule((ConditionalFormatting::HighlightRuleType)type, formula1, formula2, fmt); 72 | cf.addRange("C3:C10"); 73 | 74 | QBuffer buffer; 75 | buffer.open(QIODevice::WriteOnly); 76 | QXmlStreamWriter writer(&buffer); 77 | cf.saveToXml(writer); 78 | qDebug()<" 94 | "" 95 | "" 96 | "" 97 | ""; 98 | QVERIFY(buffer.buffer().contains(res)); 99 | } 100 | 101 | QTEST_APPLESS_MAIN(ConditionalFormattingTest) 102 | 103 | #include "tst_conditionalformattingtest.moc" 104 | -------------------------------------------------------------------------------- /tests/auto/xlsxconditionalformatting/xlsxconditionalformatting.pro: -------------------------------------------------------------------------------- 1 | QT += testlib xlsx xlsx-private 2 | CONFIG += testcase 3 | DEFINES += XLSX_TEST 4 | 5 | TARGET = tst_conditionalformattingtest 6 | CONFIG += console 7 | CONFIG -= app_bundle 8 | 9 | TEMPLATE = app 10 | 11 | SOURCES += tst_conditionalformattingtest.cpp 12 | DEFINES += SRCDIR=\\\"$$PWD/\\\" 13 | -------------------------------------------------------------------------------- /tests/auto/zipreader/tst_zipreadertest.cpp: -------------------------------------------------------------------------------- 1 | #include "private/xlsxzipreader_p.h" 2 | #include 3 | #include 4 | #include 5 | 6 | const char fileContent[] = "\x50\x4B\x03\x04\x0A\x00\x00\x00\x00\x00\x8F\x51\x25\x43\x82\x89\xD1\xF7\x05\x00\x00\x00\x05\x00\x00\x00\x09\x00\x00\x00\x68\x65\x6C\x6C\x6F\x2E\x74\x78\x74\x48\x65\x6C\x6C\x6F\x50\x4B\x03\x04\x0A\x00\x00\x00\x00\x00\xB8\x53\x25\x43\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x71\x74\x2F\x50\x4B\x03\x04\x0A\x00\x00\x00\x00\x00\x92\x51\x25\x43\x2E\x19\xFC\x34\x04\x00\x00\x00\x04\x00\x00\x00\x0B\x00\x00\x00\x71\x74\x2F\x78\x6C\x73\x78\x2E\x74\x78\x74\x58\x6C\x73\x78\x50\x4B\x01\x02\x14\x00\x0A\x00\x00\x00\x00\x00\x8F\x51\x25\x43\x82\x89\xD1\xF7\x05\x00\x00\x00\x05\x00\x00\x00\x09\x00\x00\x00\x00\x00\x00\x00\x01\x00\x20\x00\x00\x00\x00\x00\x00\x00\x68\x65\x6C\x6C\x6F\x2E\x74\x78\x74\x50\x4B\x01\x02\x14\x00\x0A\x00\x00\x00\x00\x00\xB8\x53\x25\x43\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x03\x00\x00\x00\x00\x00\x00\x00\x00\x00\x10\x00\x00\x00\x2C\x00\x00\x00\x71\x74\x2F\x50\x4B\x01\x02\x14\x00\x0A\x00\x00\x00\x00\x00\x92\x51\x25\x43\x2E\x19\xFC\x34\x04\x00\x00\x00\x04\x00\x00\x00\x0B\x00\x00\x00\x00\x00\x00\x00\x01\x00\x20\x00\x00\x00\x4D\x00\x00\x00\x71\x74\x2F\x78\x6C\x73\x78\x2E\x74\x78\x74\x50\x4B\x05\x06\x00\x00\x00\x00\x03\x00\x03\x00\xA1\x00\x00\x00\x7A\x00\x00\x00\x00\x00"; 7 | 8 | class ZipReaderTest : public QObject 9 | { 10 | Q_OBJECT 11 | 12 | public: 13 | ZipReaderTest(); 14 | 15 | private Q_SLOTS: 16 | void testFileList(); 17 | }; 18 | 19 | ZipReaderTest::ZipReaderTest() 20 | { 21 | } 22 | 23 | void ZipReaderTest::testFileList() 24 | { 25 | QByteArray data(fileContent, sizeof(fileContent) - 1); 26 | QBuffer buffer(&data); 27 | buffer.open(QIODevice::ReadOnly); 28 | 29 | QXlsx::ZipReader reader(&buffer); 30 | 31 | QStringList files = reader.filePaths(); 32 | QVERIFY(files.contains("hello.txt")); 33 | QVERIFY(files.contains("qt/xlsx.txt")); 34 | QCOMPARE(reader.fileData("hello.txt"), QByteArray("Hello")); 35 | QCOMPARE(reader.fileData("qt/xlsx.txt"), QByteArray("Xlsx")); 36 | } 37 | 38 | QTEST_APPLESS_MAIN(ZipReaderTest) 39 | 40 | #include "tst_zipreadertest.moc" 41 | -------------------------------------------------------------------------------- /tests/auto/zipreader/zipreader.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2013-09-05T10:09:38 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += testlib xlsx xlsx-private 8 | CONFIG += testcase 9 | DEFINES += XLSX_TEST 10 | 11 | TARGET = tst_zipreadertest 12 | CONFIG += console 13 | CONFIG -= app_bundle 14 | 15 | TEMPLATE = app 16 | 17 | SOURCES += tst_zipreadertest.cpp 18 | DEFINES += SRCDIR=\\\"$$PWD/\\\" 19 | -------------------------------------------------------------------------------- /tests/benchmarks/benchmarks.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS += \ 3 | xmlspace 4 | -------------------------------------------------------------------------------- /tests/benchmarks/xmlspace/tst_xmlspacetest.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | 5 | bool startsWithOrEndsWithSpace(const QString &s, int flag) 6 | { 7 | if (flag == 0) { 8 | return (s.contains(QRegularExpression("^\\s")) || s.contains(QRegularExpression("\\s$"))); 9 | } else if (flag == 1) { 10 | return (s.contains(QRegularExpression("^\\s|\\s$"))); 11 | } else if (flag == 2) { 12 | static QRegularExpression re("^\\s|\\s$"); 13 | return s.contains(re); 14 | } else if (flag == 3) { 15 | return s.startsWith(QLatin1Char(' ')) || s.endsWith(QLatin1Char(' ')) 16 | || s.startsWith(QLatin1Char('\t')) || s.endsWith(QLatin1Char('\t')) 17 | || s.startsWith(QLatin1Char('\r')) || s.endsWith(QLatin1Char('\r')) 18 | || s.startsWith(QLatin1Char('\n')) || s.endsWith(QLatin1Char('\n')); 19 | } else if (flag == 4) { 20 | //static QString spaces(" \t\n\r"); 21 | QString spaces(QStringLiteral(" \t\n\r")); 22 | return !s.isEmpty() && (spaces.contains(s.at(0))||spaces.contains(s.at(s.length()-1))); 23 | } else { 24 | return false; 25 | } 26 | } 27 | 28 | class XmlspaceTest : public QObject 29 | { 30 | Q_OBJECT 31 | 32 | public: 33 | XmlspaceTest(); 34 | 35 | private Q_SLOTS: 36 | void teststartsWithOrEndsWithSpace(); 37 | void teststartsWithOrEndsWithSpace_data(); 38 | 39 | void testCase1(); 40 | void testCase1_data(); 41 | }; 42 | 43 | XmlspaceTest::XmlspaceTest() 44 | { 45 | } 46 | 47 | void XmlspaceTest::teststartsWithOrEndsWithSpace() 48 | { 49 | QFETCH(QString, data); 50 | QFETCH(bool, res); 51 | 52 | for (int f=0; f<5; ++f) { 53 | QCOMPARE(startsWithOrEndsWithSpace(data, f), res); 54 | } 55 | } 56 | 57 | void XmlspaceTest::teststartsWithOrEndsWithSpace_data() 58 | { 59 | //QTest::addColumn("flag"); 60 | QTest::addColumn("data"); 61 | QTest::addColumn("res"); 62 | 63 | QTest::newRow("")<("flag"); 89 | QTest::newRow("0") << 0; 90 | QTest::newRow("1") << 1; 91 | QTest::newRow("2") << 2; 92 | QTest::newRow("3") << 3; 93 | QTest::newRow("4") << 4; 94 | } 95 | 96 | QTEST_APPLESS_MAIN(XmlspaceTest) 97 | 98 | #include "tst_xmlspacetest.moc" 99 | -------------------------------------------------------------------------------- /tests/benchmarks/xmlspace/xmlspace.pro: -------------------------------------------------------------------------------- 1 | QT += testlib #xlsx # xlsx-private 2 | CONFIG += testcase 3 | DEFINES += XLSX_TEST 4 | 5 | TARGET = tst_xmlspacetest 6 | CONFIG += console 7 | CONFIG -= app_bundle 8 | 9 | TEMPLATE = app 10 | 11 | 12 | SOURCES += tst_xmlspacetest.cpp 13 | DEFINES += SRCDIR=\\\"$$PWD/\\\" 14 | -------------------------------------------------------------------------------- /tests/tests.pro: -------------------------------------------------------------------------------- 1 | TEMPLATE = subdirs 2 | SUBDIRS += auto 3 | --------------------------------------------------------------------------------