mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
switch zlib to miniz, update documentation, update build system
This commit is contained in:
parent
42085a9330
commit
eb251f1e47
48
README.md
48
README.md
|
@ -2,21 +2,22 @@ xlnt
|
|||
====
|
||||
|
||||
## Introduction
|
||||
xlnt is a c++ library for reading, writing, and modifying xlsx files. The API is roughly based on openpyxl, a python library for reading and writing xlsx/xlsm files. It is still very much a work in progress, but the core development work is complete.
|
||||
xlnt is a C++11 library for reading, writing, and modifying xlsx files. The API is generally based on [openpyxl](https://bitbucket.org/openpyxl/openpyxl), a python library for reading and writing xlsx/xlsm files. It is still very much a work in progress, but the core development work is complete.
|
||||
|
||||
## Usage
|
||||
Including xlnt in your project
|
||||
```c++
|
||||
#include <xlnt.h>
|
||||
// with -Ixlnt/include
|
||||
#include <xlnt/xlnt.hpp>
|
||||
```
|
||||
|
||||
Creating a new spreadsheet and saving it
|
||||
```c++
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
ws.cell("A1") = 5;
|
||||
ws.cell("B2") = "string data";
|
||||
ws.cell("C3") = "=RAND()";
|
||||
ws.cell("A1").set_value(5);
|
||||
ws.cell("B2").set_value("string data");
|
||||
ws.cell("C3").set_formula("=RAND()");
|
||||
ws.merge_cells("C3:C4");
|
||||
ws.freeze_panes("B2");
|
||||
wb.save("book1.xlsx");
|
||||
|
@ -26,24 +27,47 @@ Opening an existing spreadsheet and printing all rows
|
|||
```c++
|
||||
xlnt::workbook wb2;
|
||||
wb2.load("book2.xlsx");
|
||||
wb2["sheet1"].get_dimensions();
|
||||
for(auto &row : wb2["sheet2"])
|
||||
|
||||
// no need to use references, iterators are only wrappers around pointers to memory in the workbook
|
||||
for(auto row : wb2["sheet2"].rows())
|
||||
{
|
||||
for(auto cell : row)
|
||||
{
|
||||
std::cout << cell.to_string() << std::endl;
|
||||
std::cout << cell.get_value().to_string() << std::endl;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Building
|
||||
xlnt is regularly built and passes all 200+ tests in GCC 4.8.2, MSVC 12, and Clang 3.3.
|
||||
xlnt is regularly built and passes all 200+ tests in GCC 4.8.2, MSVC 12, and Clang 3.4.
|
||||
|
||||
Workspaces for Visual Studio 2013, and GNU Make can be created using premake and the premake5.lua file in the build directory (requires premake5, currently available [here](https://bitbucket.org/premake/premake-dev)).
|
||||
Workspaces for Visual Studio 2013, and GNU Make can be created using premake and the premake5.lua file in the build directory (requires premake5, currently available [here](https://bitbucket.org/premake/premake-dev)). XCode workspaces can be generated using premake4.lua and premake4.
|
||||
|
||||
In Windows, with Visual Studio 2013:
|
||||
```batch
|
||||
cd build
|
||||
premake5 vs2013
|
||||
start vs2013/xlnt.sln
|
||||
```
|
||||
|
||||
In Linux, with GCC 4.8:
|
||||
```bash
|
||||
cd build
|
||||
premake5 gmake
|
||||
cd gmake
|
||||
make
|
||||
```
|
||||
|
||||
In OSX, with Clang 3.4 (can also use gmake as described above):
|
||||
```bash
|
||||
cd build
|
||||
premake4 xcode4
|
||||
open xcode4/xlnt.xcworkspace
|
||||
```
|
||||
|
||||
## Dependencies
|
||||
xlnt requires the following libraries:
|
||||
- [zlib v1.2.8](http://zlib.net/) (zlib/libpng license)
|
||||
xlnt uses the following libraries, which are included in the source tree:
|
||||
- [miniz v1.15_r4](https://code.google.com/p/miniz/) (public domain/unlicense)
|
||||
- [pugixml v1.4](http://pugixml.org/) (MIT license)
|
||||
|
||||
## License
|
||||
|
|
|
@ -9,71 +9,41 @@ project "xlnt.test"
|
|||
kind "ConsoleApp"
|
||||
language "C++"
|
||||
targetname "xlnt.test"
|
||||
targetdir "../bin"
|
||||
includedirs {
|
||||
"../include",
|
||||
"../third-party/pugixml/src",
|
||||
"../third-party/zlib",
|
||||
"../third-party/zlib/contrib/minizip",
|
||||
"../third-party/miniz",
|
||||
"/usr/local/Cellar/cxxtest/4.3"
|
||||
}
|
||||
files {
|
||||
"../tests/*.hpp",
|
||||
"../tests/runner-autogen.cpp"
|
||||
}
|
||||
links {
|
||||
"pugixml",
|
||||
"xlnt",
|
||||
"zlib"
|
||||
}
|
||||
links { "xlnt" }
|
||||
prebuildcommands { "/usr/local/Cellar/cxxtest/4.3/bin/cxxtestgen --runner=ErrorPrinter -o ../../tests/runner-autogen.cpp ../../tests/*.hpp" }
|
||||
flags {
|
||||
"Unicode",
|
||||
"NoEditAndContinue",
|
||||
"NoManifest",
|
||||
"NoPCH"
|
||||
}
|
||||
configuration "Debug"
|
||||
targetdir "../bin"
|
||||
configuration "Release"
|
||||
targetdir "../bin"
|
||||
flags { "Unicode" }
|
||||
configuration "windows"
|
||||
defines { "WIN32" }
|
||||
links { "Shlwapi" }
|
||||
postbuildcommands { "..\\..\\bin\\xlnt.test" }
|
||||
configuration "not windows"
|
||||
postbuildcommands { "../../bin/xlnt.test" }
|
||||
buildoptions {
|
||||
"-std=c++11",
|
||||
"-Wno-unknown-pragmas"
|
||||
}
|
||||
configuration { "not windows", "Debug" }
|
||||
buildoptions { "-ggdb" }
|
||||
|
||||
project "xlnt"
|
||||
kind "StaticLib"
|
||||
language "C++"
|
||||
targetdir "../lib/"
|
||||
links {
|
||||
"zlib",
|
||||
"pugixml"
|
||||
}
|
||||
includedirs {
|
||||
"../include/xlnt",
|
||||
"../third-party/pugixml/src",
|
||||
"../third-party/zlib/",
|
||||
"../third-party/zlib/contrib/minizip"
|
||||
"../third-party/miniz"
|
||||
}
|
||||
files {
|
||||
"../source/**.cpp",
|
||||
"../source/**.hpp",
|
||||
"../include/xlnt/**.hpp"
|
||||
}
|
||||
flags {
|
||||
"Unicode",
|
||||
"NoEditAndContinue",
|
||||
"NoManifest",
|
||||
"NoPCH"
|
||||
"../include/xlnt/**.hpp",
|
||||
"../third-party/pugixml/src/pugixml.cpp",
|
||||
"../third-party/miniz/miniz.c"
|
||||
}
|
||||
flags { "Unicode" }
|
||||
configuration "Debug"
|
||||
flags { "FatalWarnings" }
|
||||
configuration "windows"
|
||||
|
@ -81,55 +51,3 @@ project "xlnt"
|
|||
"WIN32",
|
||||
"_CRT_SECURE_NO_WARNINGS"
|
||||
}
|
||||
configuration "not windows"
|
||||
buildoptions {
|
||||
"-std=c++11",
|
||||
"-Wno-unknown-pragmas"
|
||||
}
|
||||
configuration { "not windows", "Debug" }
|
||||
buildoptions { "-ggdb" }
|
||||
|
||||
project "pugixml"
|
||||
kind "StaticLib"
|
||||
language "C++"
|
||||
targetdir "../lib/"
|
||||
includedirs {
|
||||
"../third-party/pugixml/src"
|
||||
}
|
||||
files {
|
||||
"../third-party/pugixml/src/pugixml.cpp"
|
||||
}
|
||||
flags {
|
||||
"Unicode",
|
||||
"NoEditAndContinue",
|
||||
"NoManifest",
|
||||
"NoPCH"
|
||||
}
|
||||
configuration "windows"
|
||||
defines { "WIN32" }
|
||||
|
||||
project "zlib"
|
||||
kind "StaticLib"
|
||||
language "C"
|
||||
targetdir "../lib/"
|
||||
includedirs {
|
||||
"../third-party/zlib/",
|
||||
"../third-party/zlib/contrib/minizip"
|
||||
}
|
||||
files {
|
||||
"../third-party/zlib/*.c",
|
||||
"../third-party/zlib/contrib/minizip/*.c"
|
||||
}
|
||||
excludes {
|
||||
"../third-party/zlib/contrib/minizip/miniunz.c",
|
||||
"../third-party/zlib/contrib/minizip/minizip.c",
|
||||
"../third-party/zlib/contrib/minizip/iowin32.c"
|
||||
}
|
||||
flags {
|
||||
"Unicode",
|
||||
"NoEditAndContinue",
|
||||
"NoManifest",
|
||||
"NoPCH"
|
||||
}
|
||||
configuration "windows"
|
||||
defines { "WIN32" }
|
||||
|
|
|
@ -15,8 +15,6 @@ project "xlnt.test"
|
|||
includedirs {
|
||||
"../include",
|
||||
"../third-party/pugixml/src",
|
||||
"../third-party/zlib",
|
||||
"../third-party/zlib/contrib/minizip",
|
||||
"../third-party/cxxtest"
|
||||
}
|
||||
files {
|
||||
|
@ -25,8 +23,7 @@ project "xlnt.test"
|
|||
}
|
||||
links {
|
||||
"pugixml",
|
||||
"xlnt",
|
||||
"zlib"
|
||||
"xlnt"
|
||||
}
|
||||
prebuildcommands { "../../third-party/cxxtest/bin/cxxtestgen --runner=ErrorPrinter -o ../../tests/runner-autogen.cpp ../../tests/*.hpp" }
|
||||
flags {
|
||||
|
@ -59,14 +56,11 @@ project "xlnt"
|
|||
warnings "Extra"
|
||||
targetdir "../lib/"
|
||||
links {
|
||||
"zlib",
|
||||
"pugixml"
|
||||
}
|
||||
includedirs {
|
||||
"../include/xlnt",
|
||||
"../third-party/pugixml/src",
|
||||
"../third-party/zlib/",
|
||||
"../third-party/zlib/contrib/minizip"
|
||||
"../third-party/pugixml/src"
|
||||
}
|
||||
files {
|
||||
"../source/**.cpp",
|
||||
|
@ -113,30 +107,3 @@ project "pugixml"
|
|||
}
|
||||
configuration "windows"
|
||||
defines { "WIN32" }
|
||||
|
||||
project "zlib"
|
||||
kind "StaticLib"
|
||||
language "C"
|
||||
warnings "Off"
|
||||
targetdir "../lib/"
|
||||
includedirs {
|
||||
"../third-party/zlib/",
|
||||
"../third-party/zlib/contrib/minizip"
|
||||
}
|
||||
files {
|
||||
"../third-party/zlib/*.c",
|
||||
"../third-party/zlib/contrib/minizip/*.c"
|
||||
}
|
||||
excludes {
|
||||
"../third-party/zlib/contrib/minizip/miniunz.c",
|
||||
"../third-party/zlib/contrib/minizip/minizip.c",
|
||||
"../third-party/zlib/contrib/minizip/iowin32.c"
|
||||
}
|
||||
flags {
|
||||
"Unicode",
|
||||
"NoEditAndContinue",
|
||||
"NoManifest",
|
||||
"NoPCH"
|
||||
}
|
||||
configuration "windows"
|
||||
defines { "WIN32" }
|
||||
|
|
|
@ -26,8 +26,8 @@
|
|||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
||||
#include <zip.h>
|
||||
#include <unzip.h>
|
||||
#define MINIZ_HEADER_FILE_ONLY
|
||||
#include <miniz.c>
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
|
@ -121,8 +121,7 @@ private:
|
|||
void start_write(bool append);
|
||||
void stop_write();
|
||||
|
||||
zipFile zip_file_;
|
||||
unzFile unzip_file_;
|
||||
mz_zip_archive zip_file_;
|
||||
state current_state_;
|
||||
std::string filename_;
|
||||
std::unordered_map<std::string, std::string> files_;
|
||||
|
|
|
@ -7,9 +7,8 @@
|
|||
namespace xlnt {
|
||||
|
||||
zip_file::zip_file(const std::string &filename, file_mode mode, file_access access)
|
||||
: zip_file_(nullptr),
|
||||
unzip_file_(nullptr),
|
||||
current_state_(state::closed),
|
||||
: zip_file_({0}),
|
||||
current_state_(state::closed),
|
||||
filename_(filename),
|
||||
modified_(false),
|
||||
// mode_(mode),
|
||||
|
@ -126,64 +125,27 @@ void zip_file::read_all()
|
|||
|
||||
change_state(state::read);
|
||||
|
||||
int result = unzGoToFirstFile(unzip_file_);
|
||||
auto num_files = zip_file_.m_total_files;
|
||||
std::size_t i = 0;
|
||||
|
||||
std::array<char, 1000> file_name_buffer = {{'\0'}};
|
||||
std::vector<char> file_buffer;
|
||||
|
||||
while(result == UNZ_OK)
|
||||
for(;i < num_files; i++)
|
||||
{
|
||||
unz_file_info file_info;
|
||||
file_name_buffer.fill('\0');
|
||||
mz_zip_archive_file_stat file_info = {0};
|
||||
|
||||
result = unzGetCurrentFileInfo(unzip_file_, &file_info, file_name_buffer.data(),
|
||||
static_cast<uLong>(file_name_buffer.size()), nullptr, 0, nullptr, 0);
|
||||
|
||||
if(result != UNZ_OK)
|
||||
if(!mz_zip_reader_file_stat(&zip_file_, i, &file_info))
|
||||
{
|
||||
throw result;
|
||||
throw std::runtime_error("stat failed");
|
||||
}
|
||||
|
||||
result = unzOpenCurrentFile(unzip_file_);
|
||||
std::string current_filename(file_info.m_filename, file_info.m_filename + strlen(file_info.m_filename));
|
||||
|
||||
if(result != UNZ_OK)
|
||||
{
|
||||
throw result;
|
||||
}
|
||||
|
||||
if(file_buffer.size() < file_info.uncompressed_size + 1)
|
||||
{
|
||||
file_buffer.resize(file_info.uncompressed_size + 1);
|
||||
}
|
||||
file_buffer[file_info.uncompressed_size] = '\0';
|
||||
|
||||
result = unzReadCurrentFile(unzip_file_, file_buffer.data(), file_info.uncompressed_size);
|
||||
|
||||
if(result != static_cast<int>(file_info.uncompressed_size))
|
||||
{
|
||||
throw result;
|
||||
}
|
||||
|
||||
std::string current_filename(file_name_buffer.begin(), file_name_buffer.begin() + file_info.size_filename);
|
||||
std::string contents(file_buffer.begin(), file_buffer.begin() + file_info.uncompressed_size);
|
||||
|
||||
if(current_filename.back() != '/')
|
||||
{
|
||||
files_[current_filename] = contents;
|
||||
}
|
||||
else
|
||||
if(mz_zip_reader_is_file_a_directory(&zip_file_, i))
|
||||
{
|
||||
directories_.push_back(current_filename);
|
||||
continue;
|
||||
}
|
||||
|
||||
result = unzCloseCurrentFile(unzip_file_);
|
||||
|
||||
if(result != UNZ_OK)
|
||||
{
|
||||
throw result;
|
||||
}
|
||||
|
||||
result = unzGoToNextFile(unzip_file_);
|
||||
files_[current_filename] = read_from_zip(current_filename);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,46 +180,52 @@ std::string zip_file::read_from_zip(const std::string &filename)
|
|||
|
||||
change_state(state::read);
|
||||
|
||||
auto result = unzLocateFile(unzip_file_, filename.c_str(), 1);
|
||||
auto num_files = (std::size_t)mz_zip_reader_get_num_files(&zip_file_);
|
||||
std::size_t i = 0;
|
||||
|
||||
if(result != UNZ_OK)
|
||||
for(;i < num_files; i++)
|
||||
{
|
||||
throw result;
|
||||
mz_zip_archive_file_stat file_info = {0};
|
||||
|
||||
if(!mz_zip_reader_file_stat(&zip_file_, i, &file_info))
|
||||
{
|
||||
throw std::runtime_error("stat failed");
|
||||
}
|
||||
|
||||
std::string current_filename(file_info.m_filename, file_info.m_filename + strlen(file_info.m_filename));
|
||||
|
||||
if(filename == current_filename)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
result = unzOpenCurrentFile(unzip_file_);
|
||||
|
||||
if(result != UNZ_OK)
|
||||
if(i == num_files)
|
||||
{
|
||||
throw result;
|
||||
throw std::runtime_error("not found");
|
||||
}
|
||||
|
||||
unz_file_info file_info;
|
||||
std::array<char, 1000> file_name_buffer;
|
||||
std::array<char, 1000> extra_field_buffer;
|
||||
std::array<char, 1000> comment_buffer;
|
||||
|
||||
unzGetCurrentFileInfo(unzip_file_, &file_info,
|
||||
file_name_buffer.data(), static_cast<uLong>(file_name_buffer.size()),
|
||||
extra_field_buffer.data(), static_cast<uLong>(extra_field_buffer.size()),
|
||||
comment_buffer.data(), static_cast<uLong>(comment_buffer.size()));
|
||||
|
||||
std::vector<char> file_buffer(file_info.uncompressed_size + 1, '\0');
|
||||
result = unzReadCurrentFile(unzip_file_, file_buffer.data(), file_info.uncompressed_size);
|
||||
|
||||
if(result != static_cast<int>(file_info.uncompressed_size))
|
||||
if(mz_zip_reader_is_file_a_directory(&zip_file_, i))
|
||||
{
|
||||
throw result;
|
||||
directories_.push_back(filename);
|
||||
return "";
|
||||
}
|
||||
|
||||
result = unzCloseCurrentFile(unzip_file_);
|
||||
std::size_t uncomp_size = 0;
|
||||
char archive_filename[260];
|
||||
std::fill(archive_filename, archive_filename + 260, '\0');
|
||||
std::copy(filename.begin(), filename.begin() + filename.length(), archive_filename);
|
||||
char *data = (char *)mz_zip_reader_extract_file_to_heap(&zip_file_, archive_filename, &uncomp_size, 0);
|
||||
|
||||
if(result != UNZ_OK)
|
||||
if(data == nullptr)
|
||||
{
|
||||
throw result;
|
||||
throw std::runtime_error("extract failed");
|
||||
}
|
||||
|
||||
return std::string(file_buffer.begin(), file_buffer.end());
|
||||
std::string content(data, data + uncomp_size);
|
||||
mz_free(data);
|
||||
|
||||
return content;
|
||||
}
|
||||
|
||||
void zip_file::write_directory_to_zip(const std::string &name, bool append)
|
||||
|
@ -268,21 +236,10 @@ void zip_file::write_directory_to_zip(const std::string &name, bool append)
|
|||
}
|
||||
|
||||
change_state(state::write, append);
|
||||
|
||||
zip_fileinfo file_info = {0};
|
||||
|
||||
int result = zipOpenNewFileInZip(zip_file_, name.c_str(), &file_info, nullptr, 0, nullptr, 0, nullptr, Z_DEFLATED, Z_DEFAULT_COMPRESSION);
|
||||
|
||||
if(result != UNZ_OK)
|
||||
|
||||
if(!mz_zip_writer_add_mem(&zip_file_, name.c_str(), nullptr, 0, MZ_BEST_COMPRESSION))
|
||||
{
|
||||
throw result;
|
||||
}
|
||||
|
||||
result = zipCloseFileInZip(zip_file_);
|
||||
|
||||
if(result != UNZ_OK)
|
||||
{
|
||||
throw result;
|
||||
throw std::runtime_error("write directory failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -295,27 +252,11 @@ void zip_file::write_to_zip(const std::string &filename, const std::string &cont
|
|||
|
||||
change_state(state::write, append);
|
||||
|
||||
zip_fileinfo file_info = {0};
|
||||
auto status = mz_zip_writer_add_mem(&zip_file_, filename.c_str(), content.c_str(), content.length(), MZ_BEST_COMPRESSION);
|
||||
|
||||
int result = zipOpenNewFileInZip(zip_file_, filename.c_str(), &file_info, nullptr, 0, nullptr, 0, nullptr, Z_DEFLATED, Z_DEFAULT_COMPRESSION);
|
||||
|
||||
if(result != UNZ_OK)
|
||||
if(!status)
|
||||
{
|
||||
throw result;
|
||||
}
|
||||
|
||||
result = zipWriteInFileInZip(zip_file_, content.data(), static_cast<int>(content.size()));
|
||||
|
||||
if(result != UNZ_OK)
|
||||
{
|
||||
throw result;
|
||||
}
|
||||
|
||||
result = zipCloseFileInZip(zip_file_);
|
||||
|
||||
if(result != UNZ_OK)
|
||||
{
|
||||
throw result;
|
||||
throw std::runtime_error("write failed");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -370,14 +311,9 @@ bool zip_file::file_exists(const std::string& name)
|
|||
|
||||
void zip_file::start_read()
|
||||
{
|
||||
if(unzip_file_ != nullptr || zip_file_ != nullptr)
|
||||
{
|
||||
throw std::runtime_error("bad state");
|
||||
}
|
||||
|
||||
unzip_file_ = unzOpen(filename_.c_str());
|
||||
|
||||
if(unzip_file_ == nullptr)
|
||||
zip_file_ = mz_zip_archive{0};
|
||||
|
||||
if(!mz_zip_reader_init_file(&zip_file_, filename_.c_str(), 0))
|
||||
{
|
||||
throw invalid_file_exception(filename_);
|
||||
}
|
||||
|
@ -385,46 +321,20 @@ void zip_file::start_read()
|
|||
|
||||
void zip_file::stop_read()
|
||||
{
|
||||
if(unzip_file_ == nullptr)
|
||||
if(!mz_zip_reader_end(&zip_file_))
|
||||
{
|
||||
throw std::runtime_error("bad state");
|
||||
throw std::runtime_error("");
|
||||
}
|
||||
|
||||
int result = unzClose(unzip_file_);
|
||||
|
||||
if(result != UNZ_OK)
|
||||
{
|
||||
throw result;
|
||||
}
|
||||
|
||||
unzip_file_ = nullptr;
|
||||
}
|
||||
|
||||
void zip_file::start_write(bool append)
|
||||
{
|
||||
if(unzip_file_ != nullptr || zip_file_ != nullptr)
|
||||
if(append && !file_exists(filename_))
|
||||
{
|
||||
throw std::runtime_error("bad state");
|
||||
throw std::runtime_error("can't append to non-existent file");
|
||||
}
|
||||
|
||||
int append_status;
|
||||
|
||||
if(append)
|
||||
{
|
||||
if(!file_exists(filename_))
|
||||
{
|
||||
throw std::runtime_error("can't append to non-existent file");
|
||||
}
|
||||
append_status = APPEND_STATUS_ADDINZIP;
|
||||
}
|
||||
else
|
||||
{
|
||||
append_status = APPEND_STATUS_CREATE;
|
||||
}
|
||||
|
||||
zip_file_ = zipOpen(filename_.c_str(), append_status);
|
||||
|
||||
if(zip_file_ == nullptr)
|
||||
if(!mz_zip_writer_init_file(&zip_file_, filename_.c_str(), 0))
|
||||
{
|
||||
if(append)
|
||||
{
|
||||
|
@ -439,21 +349,17 @@ void zip_file::start_write(bool append)
|
|||
|
||||
void zip_file::stop_write()
|
||||
{
|
||||
if(zip_file_ == nullptr)
|
||||
{
|
||||
throw std::runtime_error("bad state");
|
||||
}
|
||||
|
||||
flush();
|
||||
|
||||
int result = zipClose(zip_file_, nullptr);
|
||||
|
||||
if(result != UNZ_OK)
|
||||
if(!mz_zip_writer_finalize_archive(&zip_file_))
|
||||
{
|
||||
throw result;
|
||||
throw std::runtime_error("");
|
||||
}
|
||||
|
||||
zip_file_ = nullptr;
|
||||
if(!mz_zip_writer_end(&zip_file_))
|
||||
{
|
||||
throw std::runtime_error("");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ int main( int argc, char *argv[] ) {
|
|||
return status;
|
||||
}
|
||||
bool suite_test_cell_init = false;
|
||||
#include "c:\Users\taf656\Development\xlnt\tests\test_cell.hpp"
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_cell.hpp"
|
||||
|
||||
static test_cell suite_test_cell;
|
||||
|
||||
|
@ -256,7 +256,7 @@ public:
|
|||
void runTest() { suite_test_cell.test_cell_offset(); }
|
||||
} testDescription_suite_test_cell_test_cell_offset;
|
||||
|
||||
#include "c:\Users\taf656\Development\xlnt\tests\test_chart.hpp"
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_chart.hpp"
|
||||
|
||||
static test_chart suite_test_chart;
|
||||
|
||||
|
@ -347,7 +347,7 @@ public:
|
|||
void runTest() { suite_test_chart.test_write_chart_scatter(); }
|
||||
} testDescription_suite_test_chart_test_write_chart_scatter;
|
||||
|
||||
#include "c:\Users\taf656\Development\xlnt\tests\test_named_range.hpp"
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_named_range.hpp"
|
||||
|
||||
static test_named_range suite_test_named_range;
|
||||
|
||||
|
@ -438,7 +438,7 @@ public:
|
|||
void runTest() { suite_test_named_range.test_can_be_saved(); }
|
||||
} testDescription_suite_test_named_range_test_can_be_saved;
|
||||
|
||||
#include "c:\Users\taf656\Development\xlnt\tests\test_number_format.hpp"
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_number_format.hpp"
|
||||
|
||||
static test_number_format suite_test_number_format;
|
||||
|
||||
|
@ -541,7 +541,7 @@ public:
|
|||
void runTest() { suite_test_number_format.test_mac_date(); }
|
||||
} testDescription_suite_test_number_format_test_mac_date;
|
||||
|
||||
#include "c:\Users\taf656\Development\xlnt\tests\test_props.hpp"
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_props.hpp"
|
||||
|
||||
static test_props suite_test_props;
|
||||
|
||||
|
@ -584,7 +584,7 @@ public:
|
|||
void runTest() { suite_test_props.test_write_properties_app(); }
|
||||
} testDescription_suite_test_props_test_write_properties_app;
|
||||
|
||||
#include "c:\Users\taf656\Development\xlnt\tests\test_read.hpp"
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_read.hpp"
|
||||
|
||||
static test_read suite_test_read;
|
||||
|
||||
|
@ -777,7 +777,7 @@ public:
|
|||
void runTest() { suite_test_read.test_bad_formats_no(); }
|
||||
} testDescription_suite_test_read_test_bad_formats_no;
|
||||
|
||||
#include "c:\Users\taf656\Development\xlnt\tests\test_strings.hpp"
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_strings.hpp"
|
||||
|
||||
static test_strings suite_test_strings;
|
||||
|
||||
|
@ -808,7 +808,7 @@ public:
|
|||
void runTest() { suite_test_strings.test_formatted_string_table(); }
|
||||
} testDescription_suite_test_strings_test_formatted_string_table;
|
||||
|
||||
#include "c:\Users\taf656\Development\xlnt\tests\test_style.hpp"
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_style.hpp"
|
||||
|
||||
static test_style suite_test_style;
|
||||
|
||||
|
@ -917,7 +917,7 @@ public:
|
|||
void runTest() { suite_test_style.test_protection(); }
|
||||
} testDescription_suite_test_style_test_protection;
|
||||
|
||||
#include "c:\Users\taf656\Development\xlnt\tests\test_theme.hpp"
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_theme.hpp"
|
||||
|
||||
static test_theme suite_test_theme;
|
||||
|
||||
|
@ -930,7 +930,7 @@ public:
|
|||
void runTest() { suite_test_theme.test_write_theme(); }
|
||||
} testDescription_suite_test_theme_test_write_theme;
|
||||
|
||||
#include "c:\Users\taf656\Development\xlnt\tests\test_workbook.hpp"
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_workbook.hpp"
|
||||
|
||||
static test_workbook suite_test_workbook;
|
||||
|
||||
|
@ -1051,7 +1051,7 @@ public:
|
|||
void runTest() { suite_test_workbook.test_write_regular_float(); }
|
||||
} testDescription_suite_test_workbook_test_write_regular_float;
|
||||
|
||||
#include "c:\Users\taf656\Development\xlnt\tests\test_worksheet.hpp"
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_worksheet.hpp"
|
||||
|
||||
static test_worksheet suite_test_worksheet;
|
||||
|
||||
|
@ -1292,7 +1292,7 @@ public:
|
|||
void runTest() { suite_test_worksheet.test_page_options(); }
|
||||
} testDescription_suite_test_worksheet_test_page_options;
|
||||
|
||||
#include "c:\Users\taf656\Development\xlnt\tests\test_write.hpp"
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_write.hpp"
|
||||
|
||||
static test_write suite_test_write;
|
||||
|
||||
|
@ -1307,139 +1307,139 @@ public:
|
|||
|
||||
static class TestDescription_suite_test_write_test_write_virtual_workbook : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_write_virtual_workbook() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 34, "test_write_virtual_workbook" ) {}
|
||||
TestDescription_suite_test_write_test_write_virtual_workbook() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 32, "test_write_virtual_workbook" ) {}
|
||||
void runTest() { suite_test_write.test_write_virtual_workbook(); }
|
||||
} testDescription_suite_test_write_test_write_virtual_workbook;
|
||||
|
||||
static class TestDescription_suite_test_write_test_write_workbook_rels : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_write_workbook_rels() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 43, "test_write_workbook_rels" ) {}
|
||||
TestDescription_suite_test_write_test_write_workbook_rels() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 41, "test_write_workbook_rels" ) {}
|
||||
void runTest() { suite_test_write.test_write_workbook_rels(); }
|
||||
} testDescription_suite_test_write_test_write_workbook_rels;
|
||||
|
||||
static class TestDescription_suite_test_write_test_write_workbook : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_write_workbook() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 51, "test_write_workbook" ) {}
|
||||
TestDescription_suite_test_write_test_write_workbook() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 49, "test_write_workbook" ) {}
|
||||
void runTest() { suite_test_write.test_write_workbook(); }
|
||||
} testDescription_suite_test_write_test_write_workbook;
|
||||
|
||||
static class TestDescription_suite_test_write_test_write_string_table : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_write_string_table() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 59, "test_write_string_table" ) {}
|
||||
TestDescription_suite_test_write_test_write_string_table() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 57, "test_write_string_table" ) {}
|
||||
void runTest() { suite_test_write.test_write_string_table(); }
|
||||
} testDescription_suite_test_write_test_write_string_table;
|
||||
|
||||
static class TestDescription_suite_test_write_test_write_worksheet : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_write_worksheet() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 66, "test_write_worksheet" ) {}
|
||||
TestDescription_suite_test_write_test_write_worksheet() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 64, "test_write_worksheet" ) {}
|
||||
void runTest() { suite_test_write.test_write_worksheet(); }
|
||||
} testDescription_suite_test_write_test_write_worksheet;
|
||||
|
||||
static class TestDescription_suite_test_write_test_write_hidden_worksheet : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_write_hidden_worksheet() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 74, "test_write_hidden_worksheet" ) {}
|
||||
TestDescription_suite_test_write_test_write_hidden_worksheet() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 72, "test_write_hidden_worksheet" ) {}
|
||||
void runTest() { suite_test_write.test_write_hidden_worksheet(); }
|
||||
} testDescription_suite_test_write_test_write_hidden_worksheet;
|
||||
|
||||
static class TestDescription_suite_test_write_test_write_bool : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_write_bool() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 83, "test_write_bool" ) {}
|
||||
TestDescription_suite_test_write_test_write_bool() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 81, "test_write_bool" ) {}
|
||||
void runTest() { suite_test_write.test_write_bool(); }
|
||||
} testDescription_suite_test_write_test_write_bool;
|
||||
|
||||
static class TestDescription_suite_test_write_test_write_formula : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_write_formula() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 92, "test_write_formula" ) {}
|
||||
TestDescription_suite_test_write_test_write_formula() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 90, "test_write_formula" ) {}
|
||||
void runTest() { suite_test_write.test_write_formula(); }
|
||||
} testDescription_suite_test_write_test_write_formula;
|
||||
|
||||
static class TestDescription_suite_test_write_test_write_style : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_write_style() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 102, "test_write_style" ) {}
|
||||
TestDescription_suite_test_write_test_write_style() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 100, "test_write_style" ) {}
|
||||
void runTest() { suite_test_write.test_write_style(); }
|
||||
} testDescription_suite_test_write_test_write_style;
|
||||
|
||||
static class TestDescription_suite_test_write_test_write_height : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_write_height() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 113, "test_write_height" ) {}
|
||||
TestDescription_suite_test_write_test_write_height() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 111, "test_write_height" ) {}
|
||||
void runTest() { suite_test_write.test_write_height(); }
|
||||
} testDescription_suite_test_write_test_write_height;
|
||||
|
||||
static class TestDescription_suite_test_write_test_write_hyperlink : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_write_hyperlink() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 122, "test_write_hyperlink" ) {}
|
||||
TestDescription_suite_test_write_test_write_hyperlink() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 120, "test_write_hyperlink" ) {}
|
||||
void runTest() { suite_test_write.test_write_hyperlink(); }
|
||||
} testDescription_suite_test_write_test_write_hyperlink;
|
||||
|
||||
static class TestDescription_suite_test_write_test_write_hyperlink_rels : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_write_hyperlink_rels() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 131, "test_write_hyperlink_rels" ) {}
|
||||
TestDescription_suite_test_write_test_write_hyperlink_rels() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 129, "test_write_hyperlink_rels" ) {}
|
||||
void runTest() { suite_test_write.test_write_hyperlink_rels(); }
|
||||
} testDescription_suite_test_write_test_write_hyperlink_rels;
|
||||
|
||||
static class TestDescription_suite_test_write_test_write_hyperlink_image_rels : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_write_hyperlink_image_rels() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 145, "test_write_hyperlink_image_rels" ) {}
|
||||
TestDescription_suite_test_write_test_write_hyperlink_image_rels() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 143, "test_write_hyperlink_image_rels" ) {}
|
||||
void runTest() { suite_test_write.test_write_hyperlink_image_rels(); }
|
||||
} testDescription_suite_test_write_test_write_hyperlink_image_rels;
|
||||
|
||||
static class TestDescription_suite_test_write_test_hyperlink_value : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_hyperlink_value() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 150, "test_hyperlink_value" ) {}
|
||||
TestDescription_suite_test_write_test_hyperlink_value() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 148, "test_hyperlink_value" ) {}
|
||||
void runTest() { suite_test_write.test_hyperlink_value(); }
|
||||
} testDescription_suite_test_write_test_hyperlink_value;
|
||||
|
||||
static class TestDescription_suite_test_write_test_write_auto_filter : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_write_auto_filter() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 159, "test_write_auto_filter" ) {}
|
||||
TestDescription_suite_test_write_test_write_auto_filter() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 157, "test_write_auto_filter" ) {}
|
||||
void runTest() { suite_test_write.test_write_auto_filter(); }
|
||||
} testDescription_suite_test_write_test_write_auto_filter;
|
||||
|
||||
static class TestDescription_suite_test_write_test_write_auto_filter_filter_column : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_write_auto_filter_filter_column() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 172, "test_write_auto_filter_filter_column" ) {}
|
||||
TestDescription_suite_test_write_test_write_auto_filter_filter_column() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 170, "test_write_auto_filter_filter_column" ) {}
|
||||
void runTest() { suite_test_write.test_write_auto_filter_filter_column(); }
|
||||
} testDescription_suite_test_write_test_write_auto_filter_filter_column;
|
||||
|
||||
static class TestDescription_suite_test_write_test_write_auto_filter_sort_condition : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_write_auto_filter_sort_condition() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 177, "test_write_auto_filter_sort_condition" ) {}
|
||||
TestDescription_suite_test_write_test_write_auto_filter_sort_condition() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 175, "test_write_auto_filter_sort_condition" ) {}
|
||||
void runTest() { suite_test_write.test_write_auto_filter_sort_condition(); }
|
||||
} testDescription_suite_test_write_test_write_auto_filter_sort_condition;
|
||||
|
||||
static class TestDescription_suite_test_write_test_freeze_panes_horiz : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_freeze_panes_horiz() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 182, "test_freeze_panes_horiz" ) {}
|
||||
TestDescription_suite_test_write_test_freeze_panes_horiz() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 180, "test_freeze_panes_horiz" ) {}
|
||||
void runTest() { suite_test_write.test_freeze_panes_horiz(); }
|
||||
} testDescription_suite_test_write_test_freeze_panes_horiz;
|
||||
|
||||
static class TestDescription_suite_test_write_test_freeze_panes_vert : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_freeze_panes_vert() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 191, "test_freeze_panes_vert" ) {}
|
||||
TestDescription_suite_test_write_test_freeze_panes_vert() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 189, "test_freeze_panes_vert" ) {}
|
||||
void runTest() { suite_test_write.test_freeze_panes_vert(); }
|
||||
} testDescription_suite_test_write_test_freeze_panes_vert;
|
||||
|
||||
static class TestDescription_suite_test_write_test_freeze_panes_both : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_freeze_panes_both() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 200, "test_freeze_panes_both" ) {}
|
||||
TestDescription_suite_test_write_test_freeze_panes_both() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 198, "test_freeze_panes_both" ) {}
|
||||
void runTest() { suite_test_write.test_freeze_panes_both(); }
|
||||
} testDescription_suite_test_write_test_freeze_panes_both;
|
||||
|
||||
static class TestDescription_suite_test_write_test_long_number : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_long_number() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 209, "test_long_number" ) {}
|
||||
TestDescription_suite_test_write_test_long_number() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 207, "test_long_number" ) {}
|
||||
void runTest() { suite_test_write.test_long_number(); }
|
||||
} testDescription_suite_test_write_test_long_number;
|
||||
|
||||
static class TestDescription_suite_test_write_test_short_number : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_short_number() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 217, "test_short_number" ) {}
|
||||
TestDescription_suite_test_write_test_short_number() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 215, "test_short_number" ) {}
|
||||
void runTest() { suite_test_write.test_short_number(); }
|
||||
} testDescription_suite_test_write_test_short_number;
|
||||
|
||||
static class TestDescription_suite_test_write_test_write_images : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_write_images() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 225, "test_write_images" ) {}
|
||||
TestDescription_suite_test_write_test_write_images() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 223, "test_write_images" ) {}
|
||||
void runTest() { suite_test_write.test_write_images(); }
|
||||
} testDescription_suite_test_write_test_write_images;
|
||||
|
||||
|
|
|
@ -13,6 +13,12 @@ class test_write : public CxxTest::TestSuite
|
|||
public:
|
||||
void test_write_empty_workbook()
|
||||
{
|
||||
xlnt::workbook wbk;
|
||||
wbk.get_active_sheet().get_cell("A2").set_value("Thomas Fussell");
|
||||
wbk.get_active_sheet().get_cell("B5").set_value(88);
|
||||
wbk.get_active_sheet().get_cell("B5").get_style().set_number_format(xlnt::number_format(xlnt::number_format::format::percentage_00));
|
||||
wbk.save("/Users/thomas/Desktop/ab.xlsx");
|
||||
|
||||
if(PathHelper::FileExists(temp_file.GetFilename()))
|
||||
{
|
||||
PathHelper::DeleteFile(temp_file.GetFilename());
|
||||
|
|
4924
third-party/miniz/miniz.c
vendored
Normal file
4924
third-party/miniz/miniz.c
vendored
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user