clean up cmake build, fix warnings, improve configuration, general

housekeeping, fixes #72, fixes #70
pull/101/head
Thomas Fussell 2016-10-25 20:21:58 -04:00
parent 5479e572a4
commit c49341c82f
120 changed files with 899 additions and 831 deletions

View File

@ -15,7 +15,7 @@ init: []
install: []
before_build:
- git submodule update --init --recursive
- cmake -H. -Bbuild -G"Visual Studio 14 2015 Win64" -DSHARED=%SHARED% -DSTATIC=%STATIC% -DWITH_TESTS=ON
- cmake -H. -Bbuild -G"Visual Studio 14 2015 Win64" -DSHARED=%SHARED% -DSTATIC=%STATIC% -DWITH_TESTS=ON -DWITH_SAMPLES=ON
build:
project: build\xlnt.sln
@ -23,4 +23,5 @@ build:
verbosity: minimal
test_script:
- build\bin\xlnt.test.exe
- cd build\bin
- xlnt.test.exe

1
.gitmodules vendored
View File

@ -21,3 +21,4 @@
[submodule "third-party/botan"]
path = third-party/botan
url = https://github.com/randombit/botan
branch = master

View File

@ -40,9 +40,9 @@ script:
- cmake --version
- mkdir build
- cd build
- cmake -D SHARED=1 -D STATIC=0 -D WITH_TESTS=1 -D CMAKE_CXX_COMPILER=$COMPILER ..
- cmake -D SHARED=1 -D STATIC=0 -D WITH_TESTS=1 -D WITH_SAMPLES=1 -D CMAKE_CXX_COMPILER=$COMPILER ..
- cmake --build . --target xlnt.test
- bin/xlnt.test
- cd bin && ./xlnt.test
after_success:
- if [ "$COMPILER" = "g++-4.9" ]; then sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 90 ; fi
@ -50,8 +50,8 @@ after_success:
- if [ "$COMPILER" = "g++-4.9" ]; then sudo update-alternatives --install /usr/bin/gcov gcov /usr/bin/gcov-4.9 90 ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then rm -rf ./* ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then cmake -G "Unix Makefiles" -D DEBUG=1 -D COVERAGE=1 -D SHARED=0 -D STATIC=1 -D WITH_TESTS=1 .. ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then make VERBOSE=1 ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then cd .. && ./build/bin/xlnt.test ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then make ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then cd bin && ./xlnt.test ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then export OLDWD=$(pwd) ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then cd "build/CMakeFiles/xlnt.static.dir$(pwd)" ; pwd ; fi
- if [ "$COMPILER" = "g++-4.9" ]; then coveralls --root $OLDWD --verbose -x ".cpp" --gcov-options '\-p' --exclude include --exclude third-party --exclude tests --exclude samples --exclude benchmarks -E ".*/source/.*/tests/.*" -E ".*/build/tests/runner-autogen.cpp.*" -E ".*CompilerIdCXX/.*" ; fi

View File

@ -1,46 +1,71 @@
# Top level cmake script
cmake_minimum_required(VERSION 3.1)
project(xlnt)
project(xlnt
VERSION 0.9.0
LANGUAGES CXX C)
# Library type
option(SHARED "Set to OFF to not build shared libraries" ON)
option(STATIC "Set to ON to build static libraries" OFF)
option(COVERAGE "Generate coverage data for use in Coveralls" OFF)
option(WITH_EXAMPLES "Build examples" OFF)
option(WITH_TESTS "Build tests" OFF)
# Optional components
option(WITH_SAMPLES "Build executable code samples" OFF)
option(WITH_BENCHMARKS "Build performance benchmarks" OFF)
if(APPLE)
option(FRAMEWORK "Set to ON to package dylib and headers into a .framework, OSX only" OFF)
execute_process(COMMAND "sw_vers -productVersion | awk -F'.' '{print $1\".\"$2}'"
OUTPUT_VARIABLE OSX_VERSION)
set(CMAKE_OSX_DEPLOYMENT_TARGET ${OSX_VERSION})
# Platform specific options
if(NOT MSVC)
option(COVERAGE "Generate coverage data for use in Coveralls" OFF)
endif()
if(APPLE)
option(FRAMEWORK "Set to ON to package dylib and headers into a .framework, OSX only" OFF)
endif()
# Global language settings
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Platform specific settings
if(COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
endif()
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if(APPLE)
# Prevent a warning about deployment target not being set
execute_process(COMMAND "sw_vers -productVersion | awk -F'.' '{print $1\".\"$2}'"
OUTPUT_VARIABLE OSX_VERSION)
set(CMAKE_OSX_DEPLOYMENT_TARGET ${OSX_VERSION})
endif()
if(MSVC)
add_definitions(-DUNICODE -D_UNICODE)
endif()
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
foreach(OUTPUTCONFIG ${CMAKE_CONFIGURATION_TYPES})
string(TOUPPER ${OUTPUTCONFIG} OUTPUTCONFIG)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY_${OUTPUTCONFIG} ${CMAKE_BINARY_DIR}/bin)
endforeach()
# Define project directories
set(XLNT_INCLUDE_DIR ${CMAKE_SOURCE_DIR}/include)
set(XLNT_SOURCE_DIR ${CMAKE_SOURCE_DIR}/source)
set(THIRD_PARTY_DIR ${CMAKE_SOURCE_DIR}/third-party)
if(WITH_TESTS)
include(cmake/xlnt.test.cmake)
# Tell CMake where to find .cmake files
set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH})
# Add components according to selected options
if (WITH_SAMPLES)
add_subdirectory(samples)
endif()
include(cmake/xlnt.cmake)
if (WITH_BENCHMARKS)
add_subdirectory(benchmarks)
endif()
add_subdirectory(tests)
add_subdirectory(source)

View File

@ -0,0 +1,7 @@
project(xlnt.benchmarks)
include_directories(${XLNT_INCLUDE_DIR})
#add_executable(sample-basic ../samples/sample1.cpp)
#add_executable(sample-decrypt ../samples/decrypt.cpp)

View File

@ -1,8 +0,0 @@
set(PROJECT_VERSION_MAJOR "0")
set(PROJECT_VERSION_MINOR "9")
set(PROJECT_VERSION_PATCH "0")
set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}")
set(PROJECT_VERSION_FULL "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT_VERSION_PATCH}")
set(LIBRARY_VERSION ${PROJECT_VERSION_FULL})
set(LIBRARY_SOVERSION ${PROJECT_VERSION})

Binary file not shown.

View File

@ -1,8 +1,8 @@
if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt")
if(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
message(FATAL_ERROR "Cannot find install manifest: @CMAKE_BINARY_DIR@/install_manifest.txt")
endif(NOT EXISTS "@CMAKE_BINARY_DIR@/install_manifest.txt")
file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files)
file(READ "@CMAKE_BINARY_DIR@/install_manifest.txt" files)
string(REGEX REPLACE "\n" ";" files "${files}")
foreach(file ${files})
message(STATUS "Uninstalling $ENV{DESTDIR}${file}")

View File

@ -1,2 +0,0 @@
cd ${0%/*}
../third-party/cxxtest/bin/cxxtestgen --runner=ErrorPrinter -o "$1"/tests/runner-autogen.cpp ../source/*/tests/*.hpp

View File

@ -1,2 +0,0 @@
cd %~dp0
../third-party/cxxtest/bin/cxxtestgen --runner=ErrorPrinter -o "%1"/tests/runner-autogen.cpp ../tests/*.hpp ../source/*/tests/*.hpp

View File

@ -1,2 +0,0 @@
git submodule init
git submodule update

View File

@ -1,53 +0,0 @@
import os
import re
import sys
def title_case_to_underscore(name):
a = re.compile('((?<=[a-z0-9])[A-Z]|(?!^)[A-Z](?=[a-z]))')
return a.sub(r'_\1', name).lower()
def list_tests(filename):
f = open(filename)
in_class = False
class_name = ''
for line in f:
if line.startswith('class '):
in_class = True
class_name = line.split(' ')[1][:-2]
if '(' in class_name:
class_name = class_name.split('(')[0]
continue
if in_class and not (line.startswith(' ') or line.strip() == ''):
in_class = False
continue
if line.lstrip().startswith('def test_'):
if in_class:
print('\t' + title_case_to_underscore(class_name) + '__' + line.split()[1].split('(')[0])
else:
print('\t' + line.split()[1].split('(')[0])
def find_test_files(dir):
files = []
for f in os.listdir(dir):
if os.path.isdir(os.path.join(dir, f)):
files.extend(find_test_files(os.path.join(dir, f)))
elif os.path.isfile(os.path.join(dir, f)) and f.endswith('.py') and f.startswith('test_'):
files.append(os.path.join(dir, f))
return files
def main():
directory = sys.argv[1] if len(sys.argv) > 1 else os.path.dirname(os.path.abspath(__file__))
test_files = find_test_files(directory)
for test_file in test_files:
print(test_file.split('openpyxl/')[1], end='')
list_tests(test_file)
print()
if __name__ == '__main__':
main()

View File

@ -1,174 +0,0 @@
project(xlnt)
set(PROJECT_VENDOR "Thomas Fussell")
set(PROJECT_CONTACT "thomas.fussell@gmail.com")
set(PROJECT_URL "https://github.com/tfussell/xlnt")
set(PROJECT_DESCRIPTION "cross-platform user-friendly xlsx library for C++14")
include(cmake/VERSION.cmake)
if(NOT CMAKE_INSTALL_PREFIX)
if(MSVC)
set(CMAKE_INSTALL_PREFIX /c/Program Files/xlnt)
else()
set(CMAKE_INSTALL_PREFIX /usr/local)
endif()
endif()
set(INC_DEST_DIR ${CMAKE_INSTALL_PREFIX}/include)
if(NOT LIB_DEST_DIR)
set(LIB_DEST_DIR ${CMAKE_INSTALL_PREFIX}/lib)
endif()
if(NOT BIN_DEST_DIR)
set(BIN_DEST_DIR ${CMAKE_INSTALL_PREFIX}/bin)
endif()
include_directories(include)
include_directories(include/xlnt)
include_directories(source)
include_directories(source/detail)
include_directories(third-party/miniz)
include_directories(third-party/libstudxml)
include_directories(third-party/utfcpp/source)
include_directories(third-party/pole)
include_directories(third-party/botan)
FILE(GLOB ROOT_HEADERS include/xlnt/*.hpp)
FILE(GLOB CELL_HEADERS include/xlnt/cell/*.hpp)
FILE(GLOB CHARTS_HEADERS include/xlnt/charts/*.hpp)
FILE(GLOB CHARTSHEET_HEADERS include/xlnt/chartsheet/*.hpp)
FILE(GLOB DRAWING_HEADERS include/xlnt/drawing/*.hpp)
FILE(GLOB FORMULA_HEADERS include/xlnt/formula/*.hpp)
FILE(GLOB PACKAGING_HEADERS include/xlnt/packaging/*.hpp)
FILE(GLOB SERIALIZATION_HEADERS include/xlnt/serialization/*.hpp)
FILE(GLOB STYLES_HEADERS include/xlnt/styles/*.hpp)
FILE(GLOB UTILS_HEADERS include/xlnt/utils/*.hpp)
FILE(GLOB WORKBOOK_HEADERS include/xlnt/workbook/*.hpp)
FILE(GLOB WORKSHEET_HEADERS include/xlnt/worksheet/*.hpp)
FILE(GLOB DETAIL_HEADERS source/detail/*.hpp)
SET(HEADERS ${ROOT_HEADERS} ${CELL_HEADERS} ${CHARTS_HEADERS} ${CHARTSHEET_HEADERS} ${DRAWING_HEADERS} ${FORMULA_HEADERS} ${PACKAGING_HEADERS} ${SERIALIZATION_HEADERS} ${STYLES_HEADERS} ${UTILS_HEADERS} ${WORKBOOK_HEADERS} ${WORKSHEET_HEADERS} ${DETAIL_HEADERS})
FILE(GLOB CELL_SOURCES source/cell/*.cpp)
FILE(GLOB CHARTS_SOURCES source/charts/*.cpp)
FILE(GLOB CHARTSHEET_SOURCES source/chartsheet/*.cpp)
FILE(GLOB DRAWING_SOURCES source/drawing/*.cpp)
FILE(GLOB FORMULA_SOURCES source/formula/*.cpp)
FILE(GLOB PACKAGING_SOURCES source/packaging/*.cpp)
FILE(GLOB SERIALIZATION_SOURCES source/serialization/*.cpp)
FILE(GLOB STYLES_SOURCES source/styles/*.cpp)
FILE(GLOB UTILS_SOURCES source/utils/*.cpp)
FILE(GLOB WORKBOOK_SOURCES source/workbook/*.cpp)
FILE(GLOB WORKSHEET_SOURCES source/worksheet/*.cpp)
FILE(GLOB DETAIL_SOURCES source/detail/*.cpp)
set(SOURCES ${CELL_SOURCES} ${CHARTS_SOURCES} ${CHARTSHEET_SOURCES} ${DRAWING_SOURCES} ${FORMULA_SOURCES} ${PACKAGING_SOURCES} ${SERIALIZATION_SOURCES} ${STYLES_SOURCES} ${UTILS_SOURCES} ${WORKBOOK_SOURCES} ${WORKSHEET_SOURCES} ${DETAIL_SOURCES})
set(MINIZ ../third-party/miniz/miniz.c ../third-party/miniz/miniz.h)
set(LIBSTUDXML ../third-party/libstudxml/xml/parser.cxx ../third-party/libstudxml/xml/qname.cxx ../third-party/libstudxml/xml/serializer.cxx ../third-party/libstudxml/xml/value-traits.cxx ../third-party/libstudxml/xml/details/expat/xmlparse.c ../third-party/libstudxml/xml/details/expat/xmlrole.c ../third-party/libstudxml/xml/details/expat/xmltok_impl.c ../third-party/libstudxml/xml/details/expat/xmltok_ns.c ../third-party/libstudxml/xml/details/expat/xmltok.c ../third-party/libstudxml/xml/details/genx/char-props.c ../third-party/libstudxml/xml/details/genx/genx.c)
set(POLE ../third-party/pole/pole.cpp)
set(BOTAN ../third-party/botan/botan_all.cpp)
add_custom_command(OUTPUT ${BOTAN}
COMMAND python configure.py --minimized-build --enable-modules=sha1,aes,filters,codec_filt,cbc,ecb,sha2_32,sha2_64 --disable-shared --amalgamation
WORKING_DIRECTORY ../third-party/botan
COMMENT "Generating botan amalgamation ${BOTAN}")
if(SHARED)
add_library(xlnt.shared SHARED ${HEADERS} ${SOURCES} ${MINIZ} ${LIBSTUDXML} ${POLE} ${BOTAN})
target_compile_definitions(xlnt.shared PRIVATE XLNT_SHARED=1 LIBSTUDXML_STATIC_LIB=1)
if(MSVC)
target_compile_definitions(xlnt.shared PRIVATE XLNT_EXPORT=1 _CRT_SECURE_NO_WARNINGS=1 NOMINMAX)
set_target_properties(xlnt.shared PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\"")
endif()
install(TARGETS xlnt.shared
LIBRARY DESTINATION ${LIB_DEST_DIR}
ARCHIVE DESTINATION ${LIB_DEST_DIR}
RUNTIME DESTINATION ${BIN_DEST_DIR}
)
SET_TARGET_PROPERTIES(
xlnt.shared
PROPERTIES
OUTPUT_NAME xlnt
VERSION ${PROJECT_VERSION_FULL}
SOVERSION ${PROJECT_VERSION}
INSTALL_NAME_DIR "${LIB_DEST_DIR}"
)
if(FRAMEWORK)
add_custom_command(
TARGET xlnt.shared
POST_BUILD
COMMAND mkdir -p "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.framework/Versions/${PROJECT_VERSION_FULL}/Headers"
COMMAND cp -R ../include/xlnt/* "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.framework/Versions/${PROJECT_VERSION_FULL}/Headers"
COMMAND cp "lib/lib${PROJECT_NAME}.${PROJECT_VERSION_FULL}.dylib" "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.framework/Versions/${PROJECT_VERSION_FULL}/xlnt"
COMMAND cd "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.framework/Versions" && ln -s "${PROJECT_VERSION_FULL}" Current
COMMAND cd "${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.framework" && ln -s Versions/Current/* ./
)
endif()
endif()
if(STATIC)
add_library(xlnt.static STATIC ${HEADERS} ${SOURCES} ${MINIZ} ${LIBSTUDXML} ${POLE} ${BOTAN})
target_compile_definitions(xlnt.static PUBLIC XLNT_STATIC=1)
target_compile_definitions(xlnt.static PRIVATE LIBSTUDXML_STATIC_LIB=1)
if(MSVC)
target_compile_definitions(xlnt.static PRIVATE _CRT_SECURE_NO_WARNINGS=1 NOMINMAX)
endif()
install(TARGETS xlnt.static
LIBRARY DESTINATION ${LIB_DEST_DIR}
ARCHIVE DESTINATION ${LIB_DEST_DIR}
RUNTIME DESTINATION ${BIN_DEST_DIR}
)
SET_TARGET_PROPERTIES(
xlnt.static
PROPERTIES
OUTPUT_NAME xlnt
)
endif()
source_group(xlnt FILES ${ROOT_HEADERS})
source_group(detail FILES ${DETAIL_HEADERS} ${DETAIL_SOURCES})
source_group(cell FILES ${CELL_HEADERS} ${CELL_SOURCES})
source_group(charts FILES ${CHARTS_HEADERS} ${CHARTS_SOURCES})
source_group(chartsheet FILES ${CHARTSHEET_HEADERS} ${CHARTSHEET_SOURCES})
source_group(drawing FILES ${DRAWING_HEADERS} ${DRAWING_SOURCES})
source_group(formula FILES ${FORMULA_HEADERS} ${FORMULA_SOURCES})
source_group(packaging FILES ${PACKAGING_HEADERS} ${PACKAGING_SOURCES})
source_group(serialization FILES ${SERIALIZATION_HEADERS} ${SERIALIZATION_SOURCES})
source_group(styles FILES ${STYLES_HEADERS} ${STYLES_SOURCES})
source_group(utils FILES ${UTILS_HEADERS} ${UTILS_SOURCES})
source_group(workbook FILES ${WORKBOOK_HEADERS} ${WORKBOOK_SOURCES})
source_group(worksheet FILES ${WORKSHEET_HEADERS} ${WORKSHEET_SOURCES})
source_group(third-party\\miniz FILES ${MINIZ})
source_group(third-party\\libstudxml FILES ${LIBSTUDXML})
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
SET(PKG_CONFIG_LIBDIR ${LIB_DEST_DIR})
SET(PKG_CONFIG_INCLUDEDIR ${INC_DEST_DIR})
SET(PKG_CONFIG_LIBS "-L\${libdir} -lxlnt")
SET(PKG_CONFIG_CFLAGS "-I\${includedir}")
CONFIGURE_FILE(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/pkg-config.pc.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc"
)
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/cmake/cmake_uninstall.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
IMMEDIATE @ONLY)
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/../include/xlnt
DESTINATION include
PATTERN ".DS_Store" EXCLUDE
)
install(FILES "${CMAKE_BINARY_DIR}/${PROJECT_NAME}.pc"
DESTINATION ${LIB_DEST_DIR}/pkgconfig
)
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)

View File

@ -1,76 +0,0 @@
project(xlnt.test)
include_directories(include)
include_directories(source)
include_directories(tests)
include_directories(third-party/cxxtest)
include_directories(third-party/pugixml/src)
if(WITH_CRYPTO)
include_directories(third-party/botan/build/include)
link_directories(third-party/botan/build/lib)
endif()
FILE(GLOB CELL_TESTS source/cell/tests/test_*.hpp)
FILE(GLOB CHARTS_TESTS source/charts/tests/test_*.hpp)
FILE(GLOB CHARTSHEET_TESTS source/chartsheet/tests/test_*.hpp)
FILE(GLOB DRAWING_TESTS source/drawing/tests/test_*.hpp)
FILE(GLOB FORMULA_TESTS source/formula/tests/test_*.hpp)
FILE(GLOB PACKAGING_TESTS source/packaging/tests/test_*.hpp)
FILE(GLOB SERIALIZATION_TESTS source/serialization/tests/test_*.hpp)
FILE(GLOB STYLES_TESTS source/styles/tests/test_*.hpp)
FILE(GLOB UTILS_TESTS source/utils/tests/test_*.hpp)
FILE(GLOB WORKBOOK_TESTS source/workbook/tests/test_*.hpp)
FILE(GLOB WORKSHEET_TESTS source/worksheet/tests/test_*.hpp)
SET(TESTS ${CELL_TESTS} ${CHARTS_TESTS} ${CHARTSHEET_TESTS} ${DRAWING_TESTS} ${FORMULA_TESTS} ${PACKAGING_TESTS} ${SERIALIZATION_TESTS} ${STYLES_TESTS} ${UTILS_TESTS} ${WORKBOOK_TESTS} ${WORKSHEET_TESTS})
SET(PUGIXML ../third-party/pugixml/src/pugixml.cpp)
FILE(GLOB TEST_HELPERS_HEADERS tests/helpers/*.hpp)
FILE(GLOB TEST_HELPERS_SOURCES tests/helpers/*.cpp)
SET(TEST_HELPERS ${TEST_HELPERS_HEADERS} ${TEST_HELPERS_SOURCES})
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tests")
SET(RUNNER "${CMAKE_CURRENT_BINARY_DIR}/tests/runner-autogen.cpp")
SET_SOURCE_FILES_PROPERTIES(${RUNNER} PROPERTIES GENERATED TRUE)
add_executable(xlnt.test ${TEST_HELPERS} ${TESTS} ${RUNNER} ${PUGIXML})
source_group(helpers FILES ${TEST_HELPERS})
source_group(tests\\cell FILES ${CELL_TESTS})
source_group(tests\\charts FILES ${CHARTS_TESTS})
source_group(tests\\chartsheet FILES ${CHARTSHEET_TESTS})
source_group(tests\\drawing FILES ${DRAWING_TESTS})
source_group(tests\\formula FILES ${FORMULA_TESTS})
source_group(tests\\packaging FILES ${PACKAGING_TESTS})
source_group(tests\\serialization FILES ${SERIALIZATION_TESTS})
source_group(tests\\styles FILES ${STYLES_TESTS})
source_group(tests\\utils FILES ${UTILS_TESTS})
source_group(tests\\workbook FILES ${WORKBOOK_TESTS})
source_group(tests\\worksheet FILES ${WORKSHEET_TESTS})
source_group(runner FILES ${RUNNER})
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
if(SHARED)
target_link_libraries(xlnt.test xlnt.shared Threads::Threads)
else()
target_link_libraries(xlnt.test xlnt.static Threads::Threads)
endif()
if(MSVC)
set_target_properties(xlnt.test PROPERTIES COMPILE_FLAGS "/wd\"4251\" /wd\"4275\"")
# Needed for PathFileExists in path_helper
target_link_libraries(xlnt.test Shlwapi)
endif()
add_custom_command(OUTPUT ${RUNNER}
COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/cmake/generate-tests ${CMAKE_CURRENT_BINARY_DIR}
DEPENDS ${TESTS}
COMMENT "Generating test runner ${RUNNER}")
add_custom_target(generate-test-runner DEPENDS ${RUNNER})
add_dependencies(xlnt.test generate-test-runner)

View File

@ -16,8 +16,60 @@ Introduction
xlnt is a C++14 library for reading, writing, and modifying XLSX files as described in [ECMA 376](http://www.ecma-international.org/publications/standards/Ecma-376.htm). The API is based on [openpyxl](https://bitbucket.org/openpyxl/openpyxl), a Python library to read/write Excel 2007 xlsx/xlsm files, and ultimately on [PHPExcel](https://github.com/PHPOffice/PHPExcel), pure PHP library for reading and writing spreadsheet files upon which openpyxl was based. This project is still very much a work in progress, but the core development work is complete.
Support
+++++++
Summary of Features
+++++++++++++++++++
| Feature | Read | Edit | Write |
|---------------------------------------------------------------------|------|------|-------|
| Excel-style Workbook | ✓ | ✓ | ✓ |
| LibreOffice-style Workbook | ✓ | ✓ | ✓ |
| Numbers-style Workbook | ✓ | ✓ | ✓ |
| Encrypted Workbook (Excel 2007-2010) | ✓ | ✓ | |
| Encrypted Workbook (Excel 2013-2016) | ✓ | ✓ | |
| Excel Binary Workbook (.xlsb) | | | |
| Excel Macro-Enabled Workbook (.xlsm) | | | |
| Excel Macro-Enabled Template (.xltm) | | | |
| Document Properties | ✓ | ✓ | ✓ |
| Numeric Cell Values | ✓ | ✓ | ✓ |
| Inline String Cell Values | ✓ | ✓ | ✓ |
| Shared String Cell Values | ✓ | ✓ | ✓ |
| Shared String Text Run Formatting (e.g. varied fonts within a cell) | ✓ | ✓ | ✓ |
| Hyperlink Cell Values | | | |
| Formula Cell Values | | | |
| Formula Evaluation | | | |
| Page Margins | ✓ | ✓ | ✓ |
| Page Setup | | | |
| Print Area | | | |
| Comments | | | |
| Header and Footer | | | |
| Custom Views | | | |
| Charts | | | |
| Chartsheets | | | |
| Dialogsheets | | | |
| Themes | ✓ | | ✓ |
| Cell Styles | ✓ | ✓ | ✓ |
| Cell Formats | ✓ | ✓ | ✓ |
| Formatting->Alignment (e.g. right align) | ✓ | ✓ | ✓ |
| Formatting->Border (e.g. red cell outline) | ✓ | ✓ | ✓ |
| Formatting->Fill (e.g. green cell background) | ✓ | ✓ | ✓ |
| Formatting->Font (e.g. blue cell text) | ✓ | ✓ | ✓ |
| Formatting->Number Format (e.g. show 2 decimals) | ✓ | ✓ | ✓ |
| Formatting->Protection (e.g. hide formulas) | ✓ | ✓ | ✓ |
| Column Styles | | | |
| Row Styles | | | |
| Sheet Styles | | | |
| Conditional Formatting | | | |
| Tables | | | |
| Table Formatting | | | |
| Pivot Tables | | | |
| XLSX Thumbnail | ✓ | | ✓ |
| Custom OOXML Properties | | | |
| Custom OOXML Parts | | | |
| Drawing | | | |
| Text Box | | | |
| WordArt | | | |
| Embedded Content (e.g. images) | | | |
| Excel VBA | | | |
Sample code:
++++++++++++

View File

@ -27,7 +27,7 @@
#include <string>
#include <unordered_map>
#include <xlnt/xlnt_config.hpp> // for XLNT_CLASS, XLNT_FUNCTION
#include <xlnt/xlnt_config.hpp> // for XLNT_API, XLNT_API
#include <xlnt/cell/cell_type.hpp> // for cell_type
#include <xlnt/cell/index_types.hpp> // for column_t, row_t
@ -73,7 +73,7 @@ struct cell_impl;
/// and any other features of an Excel cell.Utilities for referencing
/// cells using Excel's 'A1' column/row nomenclature are also provided.
/// </remarks>
class XLNT_CLASS cell
class XLNT_API cell
{
public:
using type = cell_type;
@ -458,13 +458,13 @@ public:
/// <summary>
/// Return true if this cell is uninitialized.
/// </summary>
friend XLNT_FUNCTION bool operator==(std::nullptr_t, const cell &cell);
friend XLNT_API bool operator==(std::nullptr_t, const cell &cell);
/// <summary>
/// Convenience function for writing cell to an ostream.
/// Uses cell::to_string() internally.
/// </summary>
friend XLNT_FUNCTION std::ostream &operator<<(std::ostream &stream, const xlnt::cell &cell);
friend XLNT_API std::ostream &operator<<(std::ostream &stream, const xlnt::cell &cell);
private:
// make these friends so they can use the private constructor

View File

@ -38,7 +38,7 @@ class range_reference;
/// Functor for hashing a cell reference.
/// Allows for use of std::unordered_set<cell_reference, cel_reference_hash> and similar.
/// </summary>
struct XLNT_CLASS cell_reference_hash
struct XLNT_API cell_reference_hash
{
std::size_t operator()(const cell_reference &k) const;
};
@ -50,7 +50,7 @@ struct XLNT_CLASS cell_reference_hash
/// can be initialized from a string of this form or a 1-indexed ordered pair of the form
/// column, row.
/// </summary>
class XLNT_CLASS cell_reference
class XLNT_API cell_reference
{
public:
/// <summary>

View File

@ -30,7 +30,7 @@ namespace xlnt {
/// <summary>
/// Enumerates the possible types a cell can be determined by it's current value.
/// </summary>
enum class XLNT_CLASS cell_type
enum class XLNT_API cell_type
{
/// no value. note: this is different from an empty string value or 0 numeric value
null,

View File

@ -37,7 +37,7 @@ struct comment_impl;
/// <summary>
/// A comment can be applied to a cell to provide extra information.
/// </summary>
class XLNT_CLASS comment
class XLNT_API comment
{
public:
/// <summary>

View File

@ -43,7 +43,7 @@ using row_t = std::uint32_t;
/// or as a 1-indexed index. This class encapsulates both of these forms of
/// column referencing and allows for convertions between them.
/// </summary>
class XLNT_CLASS column_t
class XLNT_API column_t
{
public:
using index_t = std::uint32_t;
@ -231,27 +231,27 @@ public:
/// <summary>
/// Return the result of adding rhs to this column.
/// </summary>
friend XLNT_FUNCTION column_t operator+(column_t lhs, const column_t& rhs);
friend XLNT_API column_t operator+(column_t lhs, const column_t& rhs);
/// <summary>
/// Return the result of subtracing lhs by rhs column.
/// </summary>
friend XLNT_FUNCTION column_t operator-(column_t lhs, const column_t& rhs);
friend XLNT_API column_t operator-(column_t lhs, const column_t& rhs);
/// <summary>
/// Return the result of multiply lhs by rhs column.
/// </summary>
friend XLNT_FUNCTION column_t operator*(column_t lhs, const column_t& rhs);
friend XLNT_API column_t operator*(column_t lhs, const column_t& rhs);
/// <summary>
/// Return the result of divide lhs by rhs column.
/// </summary>
friend XLNT_FUNCTION column_t operator/(column_t lhs, const column_t& rhs);
friend XLNT_API column_t operator/(column_t lhs, const column_t& rhs);
/// <summary>
/// Return the result of mod lhs by rhs column.
/// </summary>
friend XLNT_FUNCTION column_t operator%(column_t lhs, const column_t& rhs);
friend XLNT_API column_t operator%(column_t lhs, const column_t& rhs);
/// <summary>
/// Add rhs to this column and return a reference to this column.
@ -281,27 +281,27 @@ public:
/// <summary>
/// Return true if other is to the right of this column.
/// </summary>
friend XLNT_FUNCTION bool operator>(const column_t::index_t &left, const column_t &right);
friend XLNT_API bool operator>(const column_t::index_t &left, const column_t &right);
/// <summary>
/// Return true if other is to the right of or equal to this column.
/// </summary>
friend XLNT_FUNCTION bool operator>=(const column_t::index_t &left, const column_t &right);
friend XLNT_API bool operator>=(const column_t::index_t &left, const column_t &right);
/// <summary>
/// Return true if other is to the left of this column.
/// </summary>
friend XLNT_FUNCTION bool operator<(const column_t::index_t &left, const column_t &right);
friend XLNT_API bool operator<(const column_t::index_t &left, const column_t &right);
/// <summary>
/// Return true if other is to the left of or equal to this column.
/// </summary>
friend XLNT_FUNCTION bool operator<=(const column_t::index_t &left, const column_t &right);
friend XLNT_API bool operator<=(const column_t::index_t &left, const column_t &right);
/// <summary>
/// Swap the columns that left and right refer to.
/// </summary>
friend XLNT_FUNCTION void swap(column_t &left, column_t &right);
friend XLNT_API void swap(column_t &left, column_t &right);
/// <summary>
/// Internal numeric value of this column index.
@ -313,7 +313,7 @@ public:
/// Functor for hashing a column.
/// Allows for use of std::unordered_set<column, column_hash> and similar.
/// </summary>
struct XLNT_CLASS column_hash
struct XLNT_API column_hash
{
std::size_t operator()(const column_t &k) const;
};

View File

@ -25,14 +25,14 @@
#include <string>
#include <vector>
#include <xlnt/xlnt_config.hpp> // for XLNT_CLASS, XLNT_FUNCTION
#include <xlnt/xlnt_config.hpp> // for XLNT_API, XLNT_API
#include <xlnt/cell/text_run.hpp>
namespace xlnt {
class text_run;
class XLNT_CLASS text
class XLNT_API text
{
public:
void clear();

View File

@ -24,12 +24,12 @@
#include <string>
#include <xlnt/xlnt_config.hpp> // for XLNT_CLASS, XLNT_FUNCTION
#include <xlnt/xlnt_config.hpp> // for XLNT_API, XLNT_API
#include <xlnt/utils/optional.hpp>
namespace xlnt {
class XLNT_CLASS text_run
class XLNT_API text_run
{
public:
text_run();

View File

@ -27,7 +27,7 @@
namespace xlnt {
class XLNT_CLASS axis
class XLNT_API axis
{
};

View File

@ -27,7 +27,7 @@
namespace xlnt {
class XLNT_CLASS bar_chart
class XLNT_API bar_chart
{
};

View File

@ -27,7 +27,7 @@
namespace xlnt {
class XLNT_CLASS chart
class XLNT_API chart
{
};

View File

@ -27,7 +27,7 @@
namespace xlnt {
class XLNT_CLASS error_bar
class XLNT_API error_bar
{
};

View File

@ -27,7 +27,7 @@
namespace xlnt {
class XLNT_CLASS graph_chart
class XLNT_API graph_chart
{
};

View File

@ -27,7 +27,7 @@
namespace xlnt {
class XLNT_CLASS legend
class XLNT_API legend
{
};

View File

@ -27,7 +27,7 @@
namespace xlnt {
class XLNT_CLASS line_chart
class XLNT_API line_chart
{
};

View File

@ -27,7 +27,7 @@
namespace xlnt {
class XLNT_CLASS pie_chart
class XLNT_API pie_chart
{
};

View File

@ -27,7 +27,7 @@
namespace xlnt {
class XLNT_CLASS scatter_chart
class XLNT_API scatter_chart
{
};

View File

@ -27,7 +27,7 @@
namespace xlnt {
class XLNT_CLASS series
class XLNT_API series
{
};

View File

@ -30,7 +30,7 @@ namespace xlnt {
class worksheet;
struct drawing_struct;
class XLNT_CLASS drawing
class XLNT_API drawing
{
public:
drawing();

View File

@ -27,7 +27,7 @@
namespace xlnt {
class XLNT_CLASS known_formulae
class XLNT_API known_formulae
{
};

View File

@ -27,7 +27,7 @@
namespace xlnt {
class XLNT_CLASS tokenizer
class XLNT_API tokenizer
{
};

View File

@ -33,7 +33,7 @@ namespace xlnt {
class cell_reference;
class tokenizer;
class XLNT_CLASS translator
class XLNT_API translator
{
translator(const std::string &formula, const cell_reference &ref);

View File

@ -36,7 +36,7 @@ namespace xlnt {
/// The manifest keeps track of all files in the OOXML package and
/// their type and relationships.
/// </summary>
class XLNT_CLASS manifest
class XLNT_API manifest
{
public:
/// <summary>

View File

@ -34,7 +34,7 @@ namespace xlnt {
/// <summary>
/// Specifies whether the target of a relationship is inside or outside the Package.
/// </summary>
enum class XLNT_CLASS target_mode
enum class XLNT_API target_mode
{
/// <summary>
/// The relationship references a resource that is external to the package.
@ -49,7 +49,7 @@ enum class XLNT_CLASS target_mode
/// <summary>
/// All package relationships must be one of these defined types.
/// </summary>
enum class XLNT_CLASS relationship_type
enum class XLNT_API relationship_type
{
unknown,
@ -96,7 +96,7 @@ enum class XLNT_CLASS relationship_type
/// Represents an association between a source Package or part, and a target object which can be a part or external
/// resource.
/// </summary>
class XLNT_CLASS relationship
class XLNT_API relationship
{
public:
using type = relationship_type;

View File

@ -32,7 +32,7 @@ namespace xlnt {
/// <summary>
///
/// </summary>
class XLNT_CLASS uri
class XLNT_API uri
{
public:
uri();
@ -63,7 +63,7 @@ public:
uri make_absolute(const uri &base);
uri make_reference(const uri &base);
friend XLNT_FUNCTION bool operator==(const uri &left, const uri &right);
friend XLNT_API bool operator==(const uri &left, const uri &right);
private:
bool absolute_;

View File

@ -41,7 +41,7 @@ namespace xlnt {
/// <summary>
/// Information about a specific file in zip_file.
/// </summary>
struct XLNT_CLASS zip_info
struct XLNT_API zip_info
{
/// <summary>
/// A struct representing a particular date and time.
@ -82,7 +82,7 @@ struct XLNT_CLASS zip_info
/// A compressed archive file that exists in memory which can read
/// or write to and from the filesystem, std::iostreams, and byte vectors.
/// </summary>
class XLNT_CLASS zip_file
class XLNT_API zip_file
{
public:
zip_file();

View File

@ -35,7 +35,7 @@ namespace xlnt {
/// <summary>
/// Alignment options for use in cell formats.
/// </summary>
class XLNT_CLASS alignment : public hashable
class XLNT_API alignment : public hashable
{
public:
optional<bool> shrink() const;

View File

@ -36,7 +36,7 @@ namespace xlnt {
/// <summary>
/// Describes the formatting of a particular cell.
/// </summary>
class XLNT_CLASS base_format
class XLNT_API base_format
{
public:
// Alignment

View File

@ -38,7 +38,7 @@
namespace xlnt {
enum class XLNT_CLASS border_side
enum class XLNT_API border_side
{
start,
end,
@ -56,10 +56,10 @@ namespace xlnt {
/// <summary>
/// Describes the border style of a particular cell.
/// </summary>
class XLNT_CLASS border : public hashable
class XLNT_API border : public hashable
{
public:
class XLNT_CLASS border_property
class XLNT_API border_property
{
public:
optional<class color> color() const;

View File

@ -27,7 +27,7 @@
namespace xlnt {
enum class XLNT_CLASS border_style
enum class XLNT_API border_style
{
none,
dashdot,

View File

@ -31,7 +31,7 @@
namespace xlnt {
class XLNT_CLASS indexed_color
class XLNT_API indexed_color
{
public:
indexed_color(std::size_t index);
@ -44,7 +44,7 @@ private:
std::size_t index_;
};
class XLNT_CLASS theme_color
class XLNT_API theme_color
{
public:
theme_color(std::size_t index);
@ -57,7 +57,7 @@ private:
std::size_t index_;
};
class XLNT_CLASS rgb_color
class XLNT_API rgb_color
{
public:
rgb_color(const std::string &hex_string);
@ -87,7 +87,7 @@ private:
/// <summary>
/// Colors can be applied to many parts of a cell's style.
/// </summary>
class XLNT_CLASS color : public hashable
class XLNT_API color : public hashable
{
public:
/// <summary>

View File

@ -32,7 +32,7 @@ namespace xlnt {
/// or from the top-right to bottom-left, or both, or neither.
/// Used by style->border.
/// </summary>
enum class XLNT_CLASS diagonal_direction
enum class XLNT_API diagonal_direction
{
neither,
up,

View File

@ -31,7 +31,7 @@
namespace xlnt {
enum class XLNT_CLASS pattern_fill_type
enum class XLNT_API pattern_fill_type
{
none,
solid,
@ -54,7 +54,7 @@ enum class XLNT_CLASS pattern_fill_type
gray0625
};
class XLNT_CLASS pattern_fill : public hashable
class XLNT_API pattern_fill : public hashable
{
public:
pattern_fill();
@ -81,13 +81,13 @@ private:
optional<color> background_;
};
enum class XLNT_CLASS gradient_fill_type
enum class XLNT_API gradient_fill_type
{
linear,
path
};
class XLNT_CLASS gradient_fill : public hashable
class XLNT_API gradient_fill : public hashable
{
public:
gradient_fill();
@ -151,7 +151,7 @@ private:
std::unordered_map<double, color> stops_;
};
enum class XLNT_CLASS fill_type
enum class XLNT_API fill_type
{
pattern,
gradient
@ -160,7 +160,7 @@ enum class XLNT_CLASS fill_type
/// <summary>
/// Describes the fill style of a particular cell.
/// </summary>
class XLNT_CLASS fill : public hashable
class XLNT_API fill : public hashable
{
public:
/// <summary>

View File

@ -36,7 +36,7 @@ class style;
/// <summary>
/// Describes the font style of a particular cell.
/// </summary>
class XLNT_CLASS font : public hashable
class XLNT_API font : public hashable
{
public:
enum class underline_style

View File

@ -45,7 +45,7 @@ struct stylesheet;
/// <summary>
/// Describes the formatting of a particular cell.
/// </summary>
class XLNT_CLASS format : public base_format
class XLNT_API format : public base_format
{
public:
std::size_t id() const;

View File

@ -30,7 +30,7 @@ namespace xlnt {
/// <summary>
/// Text can be aligned horizontally in these enumerated ways.
/// </summary>
enum class XLNT_CLASS horizontal_alignment
enum class XLNT_API horizontal_alignment
{
none,
general,

View File

@ -36,7 +36,7 @@ enum class calendar;
/// <summary>
/// Describes the number formatting applied to text and numbers within a certain cell.
/// </summary>
class XLNT_CLASS number_format : public hashable
class XLNT_API number_format : public hashable
{
public:
static const number_format general();

View File

@ -34,7 +34,7 @@ namespace xlnt {
/// <summary>
/// Describes the protection style of a particular cell.
/// </summary>
class XLNT_CLASS protection : public hashable
class XLNT_API protection : public hashable
{
public:
static protection unlocked_and_visible();

View File

@ -40,7 +40,7 @@ struct stylesheet;
/// Describes a style which has a name and can be applied to multiple individual
/// formats. In Excel this is a "Cell Style".
/// </summary>
class XLNT_CLASS style : public base_format
class XLNT_API style : public base_format
{
public:
std::string name() const;

View File

@ -30,7 +30,7 @@ namespace xlnt {
/// <summary>
/// Text can be aligned vertically in these enumerated ways.
/// </summary>
enum class XLNT_CLASS vertical_alignment
enum class XLNT_API vertical_alignment
{
none,
bottom,

View File

@ -30,7 +30,7 @@ namespace xlnt {
/// An enumeration of possible base dates.
/// Dates in Excel are stored as days since this base date.
/// </summary>
enum class XLNT_CLASS calendar
enum class XLNT_API calendar
{
windows_1900,
mac_1904

View File

@ -34,7 +34,7 @@ namespace xlnt {
/// It can also be initialized as a number of days since a base date
/// using date::from_number.
/// </summary>
struct XLNT_CLASS date
struct XLNT_API date
{
/// <summary>
/// Return the current date according to the system time.

View File

@ -35,7 +35,7 @@ struct time;
/// <summary>
/// A datetime is a combination of a date and a time.
/// </summary>
struct XLNT_CLASS datetime
struct XLNT_API datetime
{
/// <summary>
/// Return the current date and time according to the system time.

View File

@ -34,7 +34,7 @@ namespace xlnt {
/// <summary>
/// Parent type of all custom exceptions thrown in this library.
/// </summary>
class XLNT_CLASS exception : public std::runtime_error
class XLNT_API exception : public std::runtime_error
{
public:
exception(const std::string &message);
@ -48,7 +48,7 @@ private:
/// <summary>
/// Exception for a bad parameter value
/// </summary>
class XLNT_CLASS invalid_parameter : public exception
class XLNT_API invalid_parameter : public exception
{
public:
invalid_parameter();
@ -57,7 +57,7 @@ public:
/// <summary>
/// Exception for bad sheet names.
/// </summary>
class XLNT_CLASS invalid_sheet_title : public exception
class XLNT_API invalid_sheet_title : public exception
{
public:
invalid_sheet_title(const std::string &title);
@ -66,7 +66,7 @@ public:
/// <summary>
/// Exception when a referenced number format is not in the stylesheet.
/// </summary>
class XLNT_CLASS missing_number_format : public exception
class XLNT_API missing_number_format : public exception
{
public:
missing_number_format();
@ -75,7 +75,7 @@ public:
/// <summary>
/// Exception for trying to open a non-XLSX file.
/// </summary>
class XLNT_CLASS invalid_file : public exception
class XLNT_API invalid_file : public exception
{
public:
invalid_file(const std::string &filename);
@ -85,7 +85,7 @@ public:
/// The data submitted which cannot be used directly in Excel files. It
/// must be removed or escaped.
/// </summary>
class XLNT_CLASS illegal_character : public exception
class XLNT_API illegal_character : public exception
{
public:
illegal_character(char c);
@ -94,7 +94,7 @@ public:
/// <summary>
/// Exception for any data type inconsistencies.
/// </summary>
class XLNT_CLASS invalid_data_type : public exception
class XLNT_API invalid_data_type : public exception
{
public:
invalid_data_type();
@ -103,7 +103,7 @@ public:
/// <summary>
/// Exception for bad column names in A1-style cell references.
/// </summary>
class XLNT_CLASS invalid_column_string_index : public exception
class XLNT_API invalid_column_string_index : public exception
{
public:
invalid_column_string_index();
@ -112,7 +112,7 @@ public:
/// <summary>
/// Exception for converting between numeric and A1-style cell references.
/// </summary>
class XLNT_CLASS invalid_cell_reference : public exception
class XLNT_API invalid_cell_reference : public exception
{
public:
invalid_cell_reference(column_t column, row_t row);
@ -122,7 +122,7 @@ public:
/// <summary>
/// Exception when setting a class's attribute to an invalid value
/// </summary>
class XLNT_CLASS invalid_attribute : public exception
class XLNT_API invalid_attribute : public exception
{
public:
invalid_attribute();
@ -131,7 +131,7 @@ public:
/// <summary>
/// Exception for a key that doesn't exist in a container
/// </summary>
class XLNT_CLASS key_not_found : public exception
class XLNT_API key_not_found : public exception
{
public:
key_not_found();
@ -140,7 +140,7 @@ public:
/// <summary>
/// Exception for a workbook with no visible worksheets
/// </summary>
class XLNT_CLASS no_visible_worksheets : public exception
class XLNT_API no_visible_worksheets : public exception
{
public:
no_visible_worksheets();
@ -149,7 +149,7 @@ public:
/// <summary>
/// Debug exception for a switch that fell through to the default case
/// </summary>
class XLNT_CLASS unhandled_switch_case : public exception
class XLNT_API unhandled_switch_case : public exception
{
public:
unhandled_switch_case();
@ -158,7 +158,7 @@ public:
/// <summary>
/// Exception for attempting to use a feature which is not supported
/// </summary>
class XLNT_CLASS unsupported : public exception
class XLNT_API unsupported : public exception
{
public:
unsupported(const std::string &message);

View File

@ -39,7 +39,7 @@ namespace xlnt {
/// Return a value by combining the hashed value of v (using std::hash) with seed.
/// </summary>
template <class T>
inline void XLNT_FUNCTION hash_combine(std::size_t &seed, const T &v)
inline void XLNT_API hash_combine(std::size_t &seed, const T &v)
{
std::hash<T> hasher;
seed ^= hasher(v) + 0x9e3779b9 + (seed << 6) + (seed >> 2);

View File

@ -29,7 +29,7 @@
namespace xlnt {
class XLNT_CLASS hashable
class XLNT_API hashable
{
public:
std::size_t hash() const;

View File

@ -6,7 +6,7 @@
namespace xlnt {
template<typename T>
class XLNT_CLASS optional
class XLNT_API optional
{
public:
optional() : has_value_(false), value_(T())

View File

@ -33,7 +33,7 @@ namespace xlnt {
/// <summary>
/// Encapsulates a path that points to location in a filesystem.
/// </summary>
class XLNT_CLASS path
class XLNT_API path
{
public:
/// <summary>
@ -155,7 +155,7 @@ public:
/// </summary>
path append(const path &to_append) const;
friend XLNT_FUNCTION bool operator==(const path &left, const path &right);
friend XLNT_API bool operator==(const path &left, const path &right);
private:
/// <summary>

View File

@ -33,7 +33,7 @@ namespace xlnt {
/// minute, second, and microsecond (0-999999).
/// It can also be initialized as a fraction of a day using time::from_number.
/// </summary>
struct XLNT_CLASS time
struct XLNT_API time
{
/// <summary>
/// Return the current time according to the system time.

View File

@ -32,7 +32,7 @@ namespace xlnt {
/// Represents a span of time between two datetimes. This is
/// not fully supported yet.
/// </summary>
struct XLNT_CLASS timedelta
struct XLNT_API timedelta
{
static timedelta from_number(long double number);

View File

@ -25,13 +25,13 @@
#include <vector>
#include <utf8.h>
#include <xlnt/xlnt_config.hpp> // for XLNT_CLASS
#include <xlnt/xlnt_config.hpp> // for XLNT_API
#include <xlnt/xlnt_config.hpp>
namespace xlnt {
class XLNT_CLASS utf8string
class XLNT_API utf8string
{
public:
static utf8string from_utf8(const std::string &s);

View File

@ -33,7 +33,7 @@ namespace xlnt {
class workbook;
class worksheet;
class XLNT_CLASS const_worksheet_iterator : public std::iterator<std::bidirectional_iterator_tag, const worksheet, std::ptrdiff_t, const worksheet*, const worksheet>
class XLNT_API const_worksheet_iterator : public std::iterator<std::bidirectional_iterator_tag, const worksheet, std::ptrdiff_t, const worksheet*, const worksheet>
{
public:
const_worksheet_iterator(const workbook &wb, std::size_t index);

View File

@ -32,7 +32,7 @@ namespace xlnt {
/// <summary>
/// Security information about the OOXML document.
/// </summary>
class XLNT_CLASS document_security
class XLNT_API document_security
{
public:
document_security();

View File

@ -30,7 +30,7 @@ namespace xlnt {
/// <summary>
/// A reference to an external workbook for use in formulae.
/// </summary>
class XLNT_CLASS external_book
class XLNT_API external_book
{
};

View File

@ -34,13 +34,13 @@ class range_reference;
class worksheet;
// TODO: why is this not in a class?
std::vector<std::pair<std::string, std::string>> XLNT_FUNCTION split_named_range(const std::string &named_range_string);
std::vector<std::pair<std::string, std::string>> XLNT_API split_named_range(const std::string &named_range_string);
/// <summary>
/// A 2D range of cells in a worksheet that is referred to by name.
/// ws->get_range("A1:B2") could be replaced by ws->get_range("range1")
/// </summary>
class XLNT_CLASS named_range
class XLNT_API named_range
{
public:
using target = std::pair<worksheet, range_reference>;

View File

@ -30,7 +30,7 @@ namespace xlnt {
/// A theme is a combination of fonts, colors, and effects.
/// This isn't really supported yet.
/// </summary>
class XLNT_CLASS theme
class XLNT_API theme
{
};

View File

@ -78,7 +78,7 @@ class xlsx_producer;
/// <summary>
/// workbook is the container for all other parts of the document.
/// </summary>
class XLNT_CLASS workbook
class XLNT_API workbook
{
public:
using iterator = worksheet_iterator;

View File

@ -32,7 +32,7 @@ namespace xlnt {
/// A workbook can be opened in multiple windows with different views.
/// This class represents a particular view used by one window.
/// </summary>
class XLNT_CLASS workbook_view
class XLNT_API workbook_view
{
public:
bool auto_filter_date_grouping = false;

View File

@ -33,7 +33,7 @@ namespace xlnt {
class workbook;
class worksheet;
class XLNT_CLASS worksheet_iterator : public std::iterator<std::bidirectional_iterator_tag, worksheet, std::ptrdiff_t, worksheet*, worksheet>
class XLNT_API worksheet_iterator : public std::iterator<std::bidirectional_iterator_tag, worksheet, std::ptrdiff_t, worksheet*, worksheet>
{
public:
worksheet_iterator(workbook &wb, std::size_t index);

View File

@ -38,7 +38,7 @@ class cell_reference;
class range_reference;
enum class major_order;
class XLNT_CLASS cell_iterator : public std::iterator<std::bidirectional_iterator_tag, cell, std::ptrdiff_t, cell*, cell>
class XLNT_API cell_iterator : public std::iterator<std::bidirectional_iterator_tag, cell, std::ptrdiff_t, cell*, cell>
{
public:
cell_iterator(worksheet ws, const cell_reference &start_cell);

View File

@ -43,7 +43,7 @@ class range_reference;
/// A cell vector is a linear (1D) range of cells, either vertical or horizontal
/// depending on the major order specified in the constructor.
/// </summary>
class XLNT_CLASS cell_vector
class XLNT_API cell_vector
{
public:
using iterator = cell_iterator;

View File

@ -31,7 +31,7 @@ namespace xlnt {
/// Properties applied to a column in a worksheet.
/// Columns can have a size and a style.
/// </summary>
class XLNT_CLASS column_properties
class XLNT_API column_properties
{
public:
long double width;

View File

@ -38,7 +38,7 @@ class cell_reference;
class range_reference;
enum class major_order;
class XLNT_CLASS const_cell_iterator : public std::iterator<std::bidirectional_iterator_tag, const cell, std::ptrdiff_t, const cell*, const cell>
class XLNT_API const_cell_iterator : public std::iterator<std::bidirectional_iterator_tag, const cell, std::ptrdiff_t, const cell*, const cell>
{
public:
const_cell_iterator(worksheet ws, const cell_reference &start_cell);

View File

@ -42,7 +42,7 @@ struct worksheet_impl;
/// A const version of range_iterator which does not allow modification
/// to the dereferenced cell_vector.
/// </summary>
class XLNT_CLASS const_range_iterator : public std::iterator<std::bidirectional_iterator_tag, const cell_vector, std::ptrdiff_t, const cell_vector*, const cell_vector>
class XLNT_API const_range_iterator : public std::iterator<std::bidirectional_iterator_tag, const cell_vector, std::ptrdiff_t, const cell_vector*, const cell_vector>
{
public:
const_range_iterator(

View File

@ -33,7 +33,7 @@ namespace xlnt {
/// <summary>
/// Worksheet footer
/// </summary>
class XLNT_CLASS footer
class XLNT_API footer
{
public:
footer();

View File

@ -33,7 +33,7 @@ namespace xlnt {
/// <summary>
/// Worksheet header
/// </summary>
class XLNT_CLASS header
class XLNT_API header
{
public:
header();

View File

@ -35,7 +35,7 @@ namespace xlnt {
/// <summary>
/// Worksheet header and footer for all six possible positions.
/// </summary>
class XLNT_CLASS header_footer
class XLNT_API header_footer
{
public:
header_footer();

View File

@ -29,7 +29,7 @@ namespace xlnt {
/// <summary>
/// Defines whether iterating a range returns columns or rows sequentially.
/// </summary>
enum class XLNT_CLASS major_order
enum class XLNT_API major_order
{
column,
row

View File

@ -30,7 +30,7 @@ namespace xlnt {
/// <summary>
/// The orientation of the worksheet when it is printed.
/// </summary>
enum class XLNT_CLASS orientation
enum class XLNT_API orientation
{
portrait,
landscape

View File

@ -30,7 +30,7 @@ namespace xlnt {
/// <summary>
/// The types of page breaks.
/// </summary>
enum class XLNT_CLASS page_break
enum class XLNT_API page_break
{
none = 0,
row = 1,

View File

@ -30,7 +30,7 @@ namespace xlnt {
/// <summary>
/// Describes the margins around a worksheet for printing.
/// </summary>
class XLNT_CLASS page_margins
class XLNT_API page_margins
{
public:
page_margins();

View File

@ -34,7 +34,7 @@ namespace xlnt {
/// <summary>
/// Describes how a worksheet will be converted into a page during printing.
/// </summary>
struct XLNT_CLASS page_setup
struct XLNT_API page_setup
{
public:
page_setup();

View File

@ -31,7 +31,7 @@ namespace xlnt {
/// <summary>
///
/// </summary>
enum class XLNT_CLASS pane_state
enum class XLNT_API pane_state
{
frozen,
normal
@ -40,7 +40,7 @@ enum class XLNT_CLASS pane_state
/// <summary>
///
/// </summary>
enum class XLNT_CLASS pane_corner
enum class XLNT_API pane_corner
{
top_left,
top_right,
@ -51,7 +51,7 @@ enum class XLNT_CLASS pane_corner
/// <summary>
/// A fixed portion of a worksheet.
/// </summary>
class XLNT_CLASS pane
class XLNT_API pane
{
public:
cell_reference top_left_cell;

View File

@ -30,7 +30,7 @@ namespace xlnt {
/// <summary>
/// The possible paper sizes for printing.
/// </summary>
enum class XLNT_CLASS paper_size
enum class XLNT_API paper_size
{
letter = 1,
letter_small = 2,

View File

@ -43,7 +43,7 @@ class range_iterator;
/// <summary>
/// A range is a 2D collection of cells with defined extens that can be iterated upon.
/// </summary>
class XLNT_CLASS range
class XLNT_API range
{
public:
using iterator = range_iterator;

View File

@ -42,7 +42,7 @@ struct worksheet_impl;
/// An iterator used by worksheet and range for traversing
/// a 2D grid of cells by row/column then across that row/column.
/// </summary>
class XLNT_CLASS range_iterator : public std::iterator<std::bidirectional_iterator_tag, cell_vector, std::ptrdiff_t, cell_vector*, cell_vector>
class XLNT_API range_iterator : public std::iterator<std::bidirectional_iterator_tag, cell_vector, std::ptrdiff_t, cell_vector*, cell_vector>
{
public:
range_iterator(worksheet &ws, const range_reference &start_cell, major_order order = major_order::row);

View File

@ -31,7 +31,7 @@ namespace xlnt {
/// A range_reference describes a rectangular area of a worksheet with positive
/// width and height defined by a top-left and bottom-right corner.
/// </summary>
class XLNT_CLASS range_reference
class XLNT_API range_reference
{
public:
/// <summary>
@ -76,13 +76,13 @@ public:
bool operator!=(const char *reference_string) const;
XLNT_FUNCTION friend bool operator==(const std::string &reference_string, const range_reference &ref);
XLNT_API friend bool operator==(const std::string &reference_string, const range_reference &ref);
XLNT_FUNCTION friend bool operator==(const char *reference_string, const range_reference &ref);
XLNT_API friend bool operator==(const char *reference_string, const range_reference &ref);
XLNT_FUNCTION friend bool operator!=(const std::string &reference_string, const range_reference &ref);
XLNT_API friend bool operator!=(const std::string &reference_string, const range_reference &ref);
XLNT_FUNCTION friend bool operator!=(const char *reference_string, const range_reference &ref);
XLNT_API friend bool operator!=(const char *reference_string, const range_reference &ref);
private:
cell_reference top_left_;

View File

@ -30,7 +30,7 @@ namespace xlnt {
/// <summary>
/// The properties of a row in a worksheet.
/// </summary>
class XLNT_CLASS row_properties
class XLNT_API row_properties
{
public:
long double height;

View File

@ -32,7 +32,7 @@ namespace xlnt {
/// <summary>
/// The selected area of a worksheet.
/// </summary>
class XLNT_CLASS selection
class XLNT_API selection
{
public:
bool has_active_cell() const { return has_active_cell_; }

View File

@ -32,7 +32,7 @@ namespace xlnt {
/// <summary>
/// Protection applied to a particular worksheet to prevent it from being modified.
/// </summary>
class XLNT_CLASS sheet_protection
class XLNT_API sheet_protection
{
public:
static std::string hash_password(const std::string &password);

View File

@ -31,7 +31,7 @@ namespace xlnt {
/// Defines how a worksheet appears in the workbook.
/// A workbook must have at least one sheet which is visible at all times.
/// </summary>
enum class XLNT_CLASS sheet_state
enum class XLNT_API sheet_state
{
visible,
hidden,

View File

@ -33,7 +33,7 @@ namespace xlnt {
/// Describes a view of a worksheet.
/// Worksheets can have multiple views which show the data differently.
/// </summary>
class XLNT_CLASS sheet_view
class XLNT_API sheet_view
{
public:
pane &get_pane() { return pane_; }

View File

@ -64,7 +64,7 @@ class xlsx_producer;
/// A worksheet is a 2D array of cells starting with cell A1 in the top-left corner
/// and extending indefinitely down and right as needed.
/// </summary>
class XLNT_CLASS worksheet
class XLNT_API worksheet
{
public:
using iterator = range_iterator;

View File

@ -30,7 +30,7 @@ namespace xlnt {
/// <summary>
/// ?
/// </summary>
class XLNT_CLASS worksheet_properties
class XLNT_API worksheet_properties
{
};

View File

@ -53,6 +53,9 @@ enum class limit_style
#ifdef XLNT_EXPORT
#define XLNT_API __declspec(dllexport)
#else
// For clients of the library, supress warnings about DLL interfaces for standard library classes
#pragma warning(disable: 4251)
#pragma warning(disable: 4275)
#define XLNT_API __declspec(dllimport)
#endif
#else
@ -60,14 +63,4 @@ enum class limit_style
#endif
#endif
// If no API for classes is defined, assume default
#ifndef XLNT_CLASS
#define XLNT_CLASS XLNT_API
#endif
// If no API for functions is defined, assume default
#ifndef XLNT_FUNCTION
#define XLNT_FUNCTION XLNT_API
#endif
} // namespace xlnt

24
samples/CMakeLists.txt Normal file
View File

@ -0,0 +1,24 @@
project(xlnt.samples)
include_directories(${XLNT_INCLUDE_DIR})
add_executable(sample-basic ../samples/sample.cpp)
target_link_libraries(sample-basic xlnt.static)
set_target_properties(sample-basic
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/bin"
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_BINARY_DIR}/bin"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/bin"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/bin")
add_executable(sample-decrypt ../samples/decrypt.cpp)
target_link_libraries(sample-decrypt xlnt.static)
set_target_properties(sample-decrypt
PROPERTIES
RUNTIME_OUTPUT_DIRECTORY_DEBUG "${CMAKE_BINARY_DIR}/bin"
RUNTIME_OUTPUT_DIRECTORY_MINSIZEREL "${CMAKE_BINARY_DIR}/bin"
RUNTIME_OUTPUT_DIRECTORY_RELWITHDEBINFO "${CMAKE_BINARY_DIR}/bin"
RUNTIME_OUTPUT_DIRECTORY_RELEASE "${CMAKE_BINARY_DIR}/bin")
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/data
DESTINATION ${CMAKE_BINARY_DIR}/bin)

Some files were not shown because too many files have changed in this diff Show More