mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
still fixing things
This commit is contained in:
parent
05e2bf251b
commit
98f2c5f10a
|
@ -20,7 +20,7 @@ project "xlnt.test"
|
|||
"$(cxxtest_prefix)"
|
||||
}
|
||||
files {
|
||||
"../tests/*.h",
|
||||
"../tests/*.hpp",
|
||||
"../tests/runner-autogen.cpp"
|
||||
}
|
||||
links {
|
||||
|
@ -29,7 +29,6 @@ project "xlnt.test"
|
|||
"zlib"
|
||||
}
|
||||
prebuildcommands { "cxxtestgen --runner=ErrorPrinter -o ../../tests/runner-autogen.cpp ../../tests/*.hpp" }
|
||||
postbuildcommands { "../../bin/xlnt.test" }
|
||||
flags {
|
||||
"Unicode",
|
||||
"NoEditAndContinue",
|
||||
|
@ -44,7 +43,9 @@ project "xlnt.test"
|
|||
configuration "windows"
|
||||
defines { "WIN32" }
|
||||
links { "Shlwapi" }
|
||||
postbuildcommands { "..\\..\\bin\\xlnt.test" }
|
||||
configuration "not windows"
|
||||
postbuildcommands { "../../bin/xlnt.test" }
|
||||
buildoptions {
|
||||
"-std=c++11",
|
||||
"-Wno-unknown-pragmas"
|
||||
|
@ -69,8 +70,8 @@ project "xlnt"
|
|||
}
|
||||
files {
|
||||
"../source/**.cpp",
|
||||
"../source/**.h",
|
||||
"../include/xlnt/**.h"
|
||||
"../source/**.hpp",
|
||||
"../include/xlnt/**.hpp"
|
||||
}
|
||||
flags {
|
||||
"Unicode",
|
||||
|
@ -81,7 +82,10 @@ project "xlnt"
|
|||
configuration "Debug"
|
||||
flags { "FatalWarnings" }
|
||||
configuration "windows"
|
||||
defines { "WIN32" }
|
||||
defines {
|
||||
"WIN32",
|
||||
"_CRT_SECURE_NO_WARNINGS"
|
||||
}
|
||||
configuration "not windows"
|
||||
buildoptions {
|
||||
"-std=c++11",
|
||||
|
|
|
@ -33,6 +33,7 @@
|
|||
namespace xlnt {
|
||||
|
||||
class cell_reference;
|
||||
class relationship;
|
||||
class worksheet;
|
||||
|
||||
struct date;
|
||||
|
@ -56,15 +57,15 @@ typedef std::string comment;
|
|||
/// </remarks>
|
||||
class cell
|
||||
{
|
||||
public:
|
||||
public:
|
||||
enum class type
|
||||
{
|
||||
null,
|
||||
numeric,
|
||||
string,
|
||||
formula,
|
||||
boolean,
|
||||
error
|
||||
numeric,
|
||||
string,
|
||||
formula,
|
||||
boolean,
|
||||
error
|
||||
};
|
||||
|
||||
static const std::unordered_map<std::string, int> ErrorCodes;
|
||||
|
@ -94,8 +95,9 @@ public:
|
|||
bool is_merged() const;
|
||||
void set_merged(bool merged);
|
||||
|
||||
std::string get_hyperlink() const;
|
||||
relationship get_hyperlink() const;
|
||||
void set_hyperlink(const std::string &value);
|
||||
bool has_hyperlink() const;
|
||||
|
||||
void set_number_format(const std::string &format_code);
|
||||
|
||||
|
@ -128,6 +130,7 @@ public:
|
|||
cell &operator=(int value);
|
||||
cell &operator=(double value);
|
||||
cell &operator=(long int value);
|
||||
cell &operator=(long long value);
|
||||
cell &operator=(long double value);
|
||||
cell &operator=(const std::string &value);
|
||||
cell &operator=(const char *value);
|
||||
|
|
|
@ -48,6 +48,7 @@ enum class target_mode
|
|||
class relationship
|
||||
{
|
||||
public:
|
||||
relationship();
|
||||
relationship(const std::string &type, const std::string &r_id = "", const std::string &target_uri = "");
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -88,12 +88,14 @@ public:
|
|||
int get_index(worksheet worksheet);
|
||||
|
||||
worksheet operator[](const std::string &name);
|
||||
worksheet operator[](int index);
|
||||
worksheet operator[](std::size_t index);
|
||||
|
||||
class iterator
|
||||
{
|
||||
public:
|
||||
iterator(workbook &wb, std::size_t index);
|
||||
iterator(const iterator &);
|
||||
iterator &operator=(const iterator &);
|
||||
worksheet operator*();
|
||||
bool operator==(const iterator &comparand) const;
|
||||
bool operator!=(const iterator &comparand) const { return !(*this == comparand); }
|
||||
|
@ -112,6 +114,8 @@ public:
|
|||
{
|
||||
public:
|
||||
const_iterator(const workbook &wb, std::size_t index);
|
||||
const_iterator(const const_iterator &);
|
||||
const_iterator &operator=(const const_iterator &);
|
||||
const worksheet operator*();
|
||||
bool operator==(const const_iterator &comparand) const;
|
||||
bool operator!=(const const_iterator &comparand) const { return !(*this == comparand); }
|
||||
|
@ -150,6 +154,7 @@ public:
|
|||
|
||||
private:
|
||||
friend class worksheet;
|
||||
bool get_already_saved() const;
|
||||
detail::workbook_impl *d_;
|
||||
};
|
||||
|
||||
|
|
|
@ -49,9 +49,9 @@ struct worksheet_impl;
|
|||
class row_properties
|
||||
{
|
||||
public:
|
||||
void set_height(int height) { this->height = height; }
|
||||
void set_height(double height) { this->height = height; }
|
||||
int row_index;
|
||||
int height;
|
||||
double height;
|
||||
bool visible;
|
||||
int outline_level;
|
||||
bool collapsed;
|
||||
|
@ -183,6 +183,7 @@ public:
|
|||
const range get_range(const range_reference &reference) const;
|
||||
row_properties &get_row_properties(row_t row);
|
||||
const row_properties &get_row_properties(row_t row) const;
|
||||
bool has_row_properties(row_t row) const;
|
||||
range rows() const;
|
||||
range columns() const;
|
||||
std::list<cell> get_cell_collection();
|
||||
|
|
|
@ -37,6 +37,8 @@ class style_writer
|
|||
{
|
||||
public:
|
||||
style_writer(workbook &wb);
|
||||
style_writer(const style_writer &);
|
||||
style_writer &operator=(const style_writer &);
|
||||
std::unordered_map<std::size_t, std::string> get_style_by_hash() const;
|
||||
std::string write_table() const;
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
static std::string write_content_types(const std::pair<std::unordered_map<std::string, std::string>, std::unordered_map<std::string, std::string>> &content_types);
|
||||
static std::string write_relationships(const std::vector<std::pair<std::string, std::pair<std::string, std::string>>> &relationships);
|
||||
static std::string write_workbook_rels(const workbook &wb);
|
||||
static std::string write_worksheet_rels(worksheet ws, int n);
|
||||
static std::string write_worksheet_rels(worksheet ws, int drawing_id, int comments_id);
|
||||
static std::string write_string_table(const std::vector<std::string> &string_table);
|
||||
};
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ std::string cell::get_value() const
|
|||
case type::string:
|
||||
return d_->string_value;
|
||||
case type::numeric:
|
||||
return std::floor(d_->numeric_value) == d_->numeric_value ? std::to_string((int)d_->numeric_value) : std::to_string(d_->numeric_value);
|
||||
return std::floor(d_->numeric_value) == d_->numeric_value ? std::to_string((long long)d_->numeric_value) : std::to_string(d_->numeric_value);
|
||||
case type::formula:
|
||||
return d_->string_value;
|
||||
case type::error:
|
||||
|
@ -247,7 +247,7 @@ bool cell::operator==(double comparand) const
|
|||
|
||||
bool cell::operator==(const std::string &comparand) const
|
||||
{
|
||||
if(d_->type_ == type::string)
|
||||
if(d_->type_ == type::string || d_->type_ == type::formula)
|
||||
{
|
||||
return d_->string_value == comparand;
|
||||
}
|
||||
|
@ -357,6 +357,14 @@ cell &cell::operator=(long int value)
|
|||
return *this;
|
||||
}
|
||||
|
||||
cell &cell::operator=(long long value)
|
||||
{
|
||||
d_->is_date_ = false;
|
||||
d_->type_ = type::numeric;
|
||||
d_->numeric_value = (long double)value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
cell &cell::operator=(long double value)
|
||||
{
|
||||
d_->is_date_ = false;
|
||||
|
@ -446,44 +454,62 @@ std::string cell::to_string() const
|
|||
return "<Cell " + worksheet(d_->parent_).get_title() + "." + get_reference().to_string() + ">";
|
||||
}
|
||||
|
||||
std::string cell::get_hyperlink() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
relationship cell::get_hyperlink() const
|
||||
{
|
||||
if(!d_->has_hyperlink_)
|
||||
{
|
||||
throw std::runtime_error("no hyperlink set");
|
||||
}
|
||||
|
||||
void cell::set_hyperlink(const std::string &hyperlink)
|
||||
{
|
||||
return d_->hyperlink_;
|
||||
}
|
||||
|
||||
bool cell::has_hyperlink() const
|
||||
{
|
||||
return d_->has_hyperlink_;
|
||||
}
|
||||
|
||||
void cell::set_hyperlink(const std::string &hyperlink)
|
||||
{
|
||||
if(hyperlink.length() == 0 || std::find(hyperlink.begin(), hyperlink.end(), ':') == hyperlink.end())
|
||||
{
|
||||
throw data_type_exception();
|
||||
}
|
||||
d_->hyperlink_ = hyperlink;
|
||||
*this = hyperlink;
|
||||
}
|
||||
{
|
||||
throw data_type_exception();
|
||||
}
|
||||
|
||||
void cell::set_null()
|
||||
{
|
||||
d_->has_hyperlink_ = true;
|
||||
d_->hyperlink_ = worksheet(d_->parent_).create_relationship("hyperlink", hyperlink);
|
||||
|
||||
if(d_->type_ == type::null)
|
||||
{
|
||||
*this = hyperlink;
|
||||
}
|
||||
}
|
||||
|
||||
void cell::set_null()
|
||||
{
|
||||
d_->type_ = type::null;
|
||||
}
|
||||
}
|
||||
|
||||
void cell::set_formula(const std::string &formula)
|
||||
{
|
||||
void cell::set_formula(const std::string &formula)
|
||||
{
|
||||
if(formula.length() == 0 || formula[0] != '=')
|
||||
{
|
||||
throw data_type_exception();
|
||||
}
|
||||
{
|
||||
throw data_type_exception();
|
||||
}
|
||||
|
||||
d_->type_ = type::formula;
|
||||
d_->string_value = formula;
|
||||
}
|
||||
}
|
||||
|
||||
void cell::set_error(const std::string &error)
|
||||
{
|
||||
void cell::set_error(const std::string &error)
|
||||
{
|
||||
if(error.length() == 0 || error[0] != '#')
|
||||
{
|
||||
throw data_type_exception();
|
||||
}
|
||||
{
|
||||
throw data_type_exception();
|
||||
}
|
||||
|
||||
d_->type_ = type::error;
|
||||
d_->string_value = error;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace xlnt
|
||||
|
|
|
@ -8,7 +8,7 @@ namespace xlnt {
|
|||
time::time(long double raw_time) : hour(0), minute(0), second(0), microsecond(0)
|
||||
{
|
||||
double integer_part;
|
||||
double fractional_part = std::modf(raw_time, &integer_part);
|
||||
double fractional_part = std::modf((double)raw_time, &integer_part);
|
||||
fractional_part *= 24;
|
||||
hour = (int)fractional_part;
|
||||
fractional_part = 60 * (fractional_part - hour);
|
||||
|
|
|
@ -4,11 +4,11 @@
|
|||
namespace xlnt {
|
||||
namespace detail {
|
||||
|
||||
cell_impl::cell_impl() : parent_(nullptr), type_(cell::type::null), column(0), row(0), style_(nullptr)
|
||||
cell_impl::cell_impl() : parent_(nullptr), type_(cell::type::null), column(0), row(0), style_(nullptr), merged(false)
|
||||
{
|
||||
}
|
||||
|
||||
cell_impl::cell_impl(worksheet_impl *parent, int column_index, int row_index) : parent_(parent), type_(cell::type::null), column(column_index), row(row_index), style_(nullptr)
|
||||
cell_impl::cell_impl(worksheet_impl *parent, int column_index, int row_index) : parent_(parent), type_(cell::type::null), column(column_index), row(row_index), style_(nullptr), merged(false)
|
||||
{
|
||||
}
|
||||
|
||||
|
|
|
@ -21,7 +21,8 @@ struct cell_impl
|
|||
cell::type type_;
|
||||
long double numeric_value;
|
||||
std::string string_value;
|
||||
std::string hyperlink_;
|
||||
bool has_hyperlink_;
|
||||
relationship hyperlink_;
|
||||
column_t column;
|
||||
row_t row;
|
||||
bool merged;
|
||||
|
|
|
@ -8,6 +8,7 @@ namespace detail {
|
|||
struct workbook_impl
|
||||
{
|
||||
workbook_impl(optimization o);
|
||||
bool already_saved_;
|
||||
bool optimized_read_;
|
||||
bool optimized_write_;
|
||||
bool guess_types_;
|
||||
|
|
|
@ -32,4 +32,10 @@ cell_coordinates_exception::cell_coordinates_exception(const std::string &coord_
|
|||
|
||||
}
|
||||
|
||||
workbook_already_saved::workbook_already_saved()
|
||||
: std::runtime_error("")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
} // namespace xlnt
|
||||
|
|
|
@ -24,7 +24,7 @@ std::unordered_map<std::string, std::pair<std::string, std::string>> reader::rea
|
|||
std::string id = relationship.attribute("Id").as_string();
|
||||
std::string type = relationship.attribute("Type").as_string();
|
||||
std::string target = relationship.attribute("Target").as_string();
|
||||
relationships[id] = std::make_pair(type, target);
|
||||
relationships[id] = std::make_pair(target, type);
|
||||
}
|
||||
|
||||
return relationships;
|
||||
|
@ -59,12 +59,12 @@ std::string reader::determine_document_type(const std::unordered_map<std::string
|
|||
{
|
||||
auto relationship_match = std::find_if(root_relationships.begin(), root_relationships.end(),
|
||||
[](const std::pair<std::string, std::pair<std::string, std::string>> &v)
|
||||
{ return v.second.first == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"; });
|
||||
{ return v.second.second == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"; });
|
||||
std::string type;
|
||||
|
||||
if(relationship_match != root_relationships.end())
|
||||
{
|
||||
std::string office_document_relationship = relationship_match->second.second;
|
||||
std::string office_document_relationship = relationship_match->second.first;
|
||||
|
||||
if(office_document_relationship[0] != '/')
|
||||
{
|
||||
|
|
|
@ -11,4 +11,8 @@ relationship::relationship(const std::string &t, const std::string &r_id, const
|
|||
}
|
||||
}
|
||||
|
||||
relationship::relationship() : id_(""), source_uri_(""), target_uri_("")
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace xlnt
|
||||
|
|
|
@ -1,8 +1,11 @@
|
|||
#include <algorithm>
|
||||
#include <array>
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <pugixml.hpp>
|
||||
|
||||
#include <Windows.h>
|
||||
|
||||
#include "workbook/workbook.hpp"
|
||||
#include "common/exceptions.hpp"
|
||||
#include "drawing/drawing.hpp"
|
||||
|
@ -16,9 +19,29 @@
|
|||
#include "detail/workbook_impl.hpp"
|
||||
#include "detail/worksheet_impl.hpp"
|
||||
|
||||
static std::string CreateTemporaryFilename()
|
||||
{
|
||||
#ifdef _WIN32
|
||||
std::array<TCHAR, MAX_PATH> buffer;
|
||||
DWORD result = GetTempPath(static_cast<DWORD>(buffer.size()), buffer.data());
|
||||
if(result > MAX_PATH)
|
||||
{
|
||||
throw std::runtime_error("buffer is too small");
|
||||
}
|
||||
if(result == 0)
|
||||
{
|
||||
throw std::runtime_error("GetTempPath failed");
|
||||
}
|
||||
std::string directory(buffer.begin(), buffer.begin() + result);
|
||||
return directory + "xlnt.xlsx";
|
||||
#else
|
||||
return "/tmp/xlsx.xlnt";
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace xlnt {
|
||||
namespace detail {
|
||||
workbook_impl::workbook_impl(optimization o) : optimized_read_(o == optimization::read), optimized_write_(o == optimization::write), active_sheet_index_(0)
|
||||
workbook_impl::workbook_impl(optimization o) : already_saved_(false), optimized_read_(o == optimization::read), optimized_write_(o == optimization::write), active_sheet_index_(0)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -42,6 +65,11 @@ workbook::iterator::iterator(workbook &wb, std::size_t index) : wb_(wb), index_(
|
|||
|
||||
}
|
||||
|
||||
workbook::iterator::iterator(const iterator &rhs) : wb_(rhs.wb_), index_(rhs.index_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
worksheet workbook::iterator::operator*()
|
||||
{
|
||||
return wb_[index_];
|
||||
|
@ -70,6 +98,11 @@ workbook::const_iterator::const_iterator(const workbook &wb, std::size_t index)
|
|||
|
||||
}
|
||||
|
||||
workbook::const_iterator::const_iterator(const const_iterator &rhs) : wb_(rhs.wb_), index_(rhs.index_)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const worksheet workbook::const_iterator::operator*()
|
||||
{
|
||||
return wb_.get_sheet_by_index(index_);
|
||||
|
@ -121,6 +154,11 @@ worksheet workbook::get_active_sheet()
|
|||
return worksheet(&d_->worksheets_[d_->active_sheet_index_]);
|
||||
}
|
||||
|
||||
bool workbook::get_already_saved() const
|
||||
{
|
||||
return d_->already_saved_;
|
||||
}
|
||||
|
||||
bool workbook::has_named_range(const std::string &name) const
|
||||
{
|
||||
for(auto worksheet : *this)
|
||||
|
@ -150,7 +188,6 @@ worksheet workbook::create_sheet()
|
|||
|
||||
d_->worksheets_.emplace_back(this, title);
|
||||
worksheet ws(&d_->worksheets_.back());
|
||||
ws.get_cell("A1");
|
||||
|
||||
return ws;
|
||||
}
|
||||
|
@ -233,14 +270,18 @@ range workbook::get_named_range(const std::string &name)
|
|||
|
||||
bool workbook::load(const std::vector<unsigned char> &data)
|
||||
{
|
||||
std::ofstream tmp;
|
||||
tmp.open("/tmp/xlnt.xlsx", std::ios::out);
|
||||
for(auto c : data)
|
||||
std::string temp_file = CreateTemporaryFilename();
|
||||
|
||||
std::ofstream tmp;
|
||||
tmp.open(temp_file, std::ios::out | std::ios::binary);
|
||||
for(auto c : data)
|
||||
{
|
||||
tmp.put(c);
|
||||
tmp.put(c);
|
||||
}
|
||||
load("/tmp/xlnt.xlsx");
|
||||
return true;
|
||||
tmp.close();
|
||||
load(temp_file);
|
||||
std::remove(temp_file.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
bool workbook::load(const std::string &filename)
|
||||
|
@ -279,7 +320,7 @@ bool workbook::load(const std::string &filename)
|
|||
auto relation_id = sheet_node.attribute("r:id").as_string();
|
||||
auto ws = create_sheet(sheet_node.attribute("name").as_string());
|
||||
std::string sheet_filename("xl/");
|
||||
sheet_filename += workbook_relationships[relation_id].second;
|
||||
sheet_filename += workbook_relationships[relation_id].first;
|
||||
xlnt::reader::read_worksheet(ws, f.get_file_contents(sheet_filename).c_str(), shared_strings);
|
||||
}
|
||||
|
||||
|
@ -380,7 +421,7 @@ worksheet workbook::operator[](const std::string &name)
|
|||
return get_sheet_by_name(name);
|
||||
}
|
||||
|
||||
worksheet workbook::operator[](int index)
|
||||
worksheet workbook::operator[](std::size_t index)
|
||||
{
|
||||
return worksheet(&d_->worksheets_[index]);
|
||||
}
|
||||
|
@ -390,20 +431,38 @@ void workbook::clear()
|
|||
d_->worksheets_.clear();
|
||||
}
|
||||
|
||||
bool workbook::get_optimized_write() const
|
||||
{
|
||||
return d_->optimized_write_;
|
||||
}
|
||||
|
||||
bool workbook::save(std::vector<unsigned char> &data)
|
||||
{
|
||||
save("/tmp/xlnt.xlsx");
|
||||
std::ifstream tmp;
|
||||
tmp.open("/tmp/xlnt.xlsx");
|
||||
auto char_data = std::vector<char>((std::istreambuf_iterator<char>(tmp)),
|
||||
std::istreambuf_iterator<char>());
|
||||
data = std::vector<unsigned char>(char_data.begin(), char_data.end());
|
||||
return true;
|
||||
auto temp_file = CreateTemporaryFilename();
|
||||
save(temp_file);
|
||||
std::ifstream tmp;
|
||||
tmp.open(temp_file, std::ios::in | std::ios::binary);
|
||||
auto char_data = std::vector<char>((std::istreambuf_iterator<char>(tmp)),
|
||||
std::istreambuf_iterator<char>());
|
||||
data = std::vector<unsigned char>(char_data.begin(), char_data.end());
|
||||
tmp.close();
|
||||
std::remove(temp_file.c_str());
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
bool workbook::save(const std::string &filename)
|
||||
{
|
||||
if(d_->optimized_write_)
|
||||
{
|
||||
if(d_->already_saved_)
|
||||
{
|
||||
throw workbook_already_saved();
|
||||
}
|
||||
|
||||
d_->already_saved_ = true;
|
||||
}
|
||||
|
||||
zip_file f(filename, file_mode::create, file_access::write);
|
||||
|
||||
std::pair<std::unordered_map<std::string, std::string>, std::unordered_map<std::string, std::string>> content_types =
|
||||
|
@ -426,17 +485,17 @@ bool workbook::save(const std::string &filename)
|
|||
|
||||
std::vector<std::pair<std::string, std::pair<std::string, std::string>>> root_rels =
|
||||
{
|
||||
{"rId3", {"http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties", "docProps/app.xml"}},
|
||||
{"rId2", {"http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties", "docProps/core.xml"}},
|
||||
{"rId1", {"http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument", "xl/workbook.xml"}}
|
||||
{"rId3", {"docProps/app.xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/extended-properties"}},
|
||||
{"rId2", {"docProps/core.xml", "http://schemas.openxmlformats.org/package/2006/relationships/metadata/core-properties"}},
|
||||
{"rId1", {"xl/workbook.xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument"}}
|
||||
};
|
||||
f.set_file_contents("_rels/.rels", writer::write_relationships(root_rels));
|
||||
|
||||
std::vector<std::pair<std::string, std::pair<std::string, std::string>>> workbook_rels =
|
||||
{
|
||||
{"rId1", {"http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet", "worksheets/sheet1.xml"}},
|
||||
{"rId2", {"http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles", "styles.xml"}},
|
||||
{"rId3", {"http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme", "theme/theme1.xml"}}
|
||||
{"rId1", {"worksheets/sheet1.xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet"}},
|
||||
{"rId2", {"styles.xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"}},
|
||||
{"rId3", {"theme/theme1.xml", "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"}}
|
||||
};
|
||||
f.set_file_contents("xl/_rels/workbook.xml.rels", writer::write_relationships(workbook_rels));
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
#include "common/relationship.hpp"
|
||||
#include "workbook/workbook.hpp"
|
||||
#include "detail/worksheet_impl.hpp"
|
||||
#include "common/exceptions.hpp"
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
|
@ -193,6 +194,11 @@ row_properties &worksheet::get_row_properties(row_t row)
|
|||
return d_->row_properties_[row];
|
||||
}
|
||||
|
||||
bool worksheet::has_row_properties(row_t row) const
|
||||
{
|
||||
return d_->row_properties_.find(row) != d_->row_properties_.end();
|
||||
}
|
||||
|
||||
range worksheet::get_named_range(const std::string &name)
|
||||
{
|
||||
if(!has_named_range(name))
|
||||
|
@ -341,6 +347,11 @@ void worksheet::unmerge_cells(const range_reference &reference)
|
|||
|
||||
void worksheet::append(const std::vector<std::string> &cells)
|
||||
{
|
||||
if(d_->parent_->get_optimized_write() && d_->parent_->get_already_saved())
|
||||
{
|
||||
throw workbook_already_saved();
|
||||
}
|
||||
|
||||
int row = get_highest_row();
|
||||
|
||||
if(d_->cell_map_.size() == 0)
|
||||
|
@ -358,6 +369,11 @@ void worksheet::append(const std::vector<std::string> &cells)
|
|||
|
||||
void worksheet::append(const std::vector<int> &cells)
|
||||
{
|
||||
if(d_->parent_->get_optimized_write() && d_->parent_->get_already_saved())
|
||||
{
|
||||
throw workbook_already_saved();
|
||||
}
|
||||
|
||||
int row = get_highest_row();
|
||||
|
||||
if(d_->cell_map_.size() == 0)
|
||||
|
@ -375,6 +391,11 @@ void worksheet::append(const std::vector<int> &cells)
|
|||
|
||||
void worksheet::append(const std::vector<date> &cells)
|
||||
{
|
||||
if(d_->parent_->get_optimized_write() && d_->parent_->get_already_saved())
|
||||
{
|
||||
throw workbook_already_saved();
|
||||
}
|
||||
|
||||
int row = get_highest_row();
|
||||
|
||||
if(d_->cell_map_.size() == 0)
|
||||
|
@ -392,6 +413,11 @@ void worksheet::append(const std::vector<date> &cells)
|
|||
|
||||
void worksheet::append(const std::unordered_map<std::string, std::string> &cells)
|
||||
{
|
||||
if(d_->parent_->get_optimized_write() && d_->parent_->get_already_saved())
|
||||
{
|
||||
throw workbook_already_saved();
|
||||
}
|
||||
|
||||
int row = get_highest_row() - 1;
|
||||
|
||||
if(d_->cell_map_.size() != 0)
|
||||
|
@ -407,6 +433,11 @@ void worksheet::append(const std::unordered_map<std::string, std::string> &cells
|
|||
|
||||
void worksheet::append(const std::unordered_map<int, std::string> &cells)
|
||||
{
|
||||
if(d_->parent_->get_optimized_write() && d_->parent_->get_already_saved())
|
||||
{
|
||||
throw workbook_already_saved();
|
||||
}
|
||||
|
||||
int row = get_highest_row() - 1;
|
||||
|
||||
if(d_->cell_map_.size() != 0)
|
||||
|
|
1820
source/writer.cpp
1820
source/writer.cpp
File diff suppressed because it is too large
Load Diff
|
@ -59,7 +59,7 @@ public:
|
|||
#elif defined(_WIN32)
|
||||
|
||||
std::array<TCHAR, MAX_PATH> buffer;
|
||||
DWORD result = GetModuleFileName(nullptr, buffer.data(), buffer.size());
|
||||
DWORD result = GetModuleFileName(nullptr, buffer.data(), (DWORD)buffer.size());
|
||||
|
||||
if(result == 0 || result == buffer.size())
|
||||
{
|
||||
|
|
|
@ -21,12 +21,12 @@ int main( int argc, char *argv[] ) {
|
|||
return status;
|
||||
}
|
||||
bool suite_test_cell_init = false;
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_cell.hpp"
|
||||
#include "C:\Users\taf656\Development\xlnt\tests\test_cell.hpp"
|
||||
|
||||
static test_cell suite_test_cell;
|
||||
|
||||
static CxxTest::List Tests_test_cell = { 0, 0 };
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_cell( "/Users/thomas/Development/xlnt/tests/test_cell.hpp", 9, "test_cell", suite_test_cell, Tests_test_cell );
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_cell( "../../tests/test_cell.hpp", 9, "test_cell", suite_test_cell, Tests_test_cell );
|
||||
|
||||
static class TestDescription_suite_test_cell_test_coordinates : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
|
@ -184,12 +184,12 @@ public:
|
|||
void runTest() { suite_test_cell.test_is_not_date_color_format(); }
|
||||
} testDescription_suite_test_cell_test_is_not_date_color_format;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_chart.hpp"
|
||||
#include "C:\Users\taf656\Development\xlnt\tests\test_chart.hpp"
|
||||
|
||||
static test_chart suite_test_chart;
|
||||
|
||||
static CxxTest::List Tests_test_chart = { 0, 0 };
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_chart( "/Users/thomas/Development/xlnt/tests/test_chart.hpp", 8, "test_chart", suite_test_chart, Tests_test_chart );
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_chart( "../../tests/test_chart.hpp", 8, "test_chart", suite_test_chart, Tests_test_chart );
|
||||
|
||||
static class TestDescription_suite_test_chart_test_write_title : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
|
@ -275,49 +275,49 @@ public:
|
|||
void runTest() { suite_test_chart.test_write_chart_scatter(); }
|
||||
} testDescription_suite_test_chart_test_write_chart_scatter;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_dump.hpp"
|
||||
#include "C:\Users\taf656\Development\xlnt\tests\test_dump.hpp"
|
||||
|
||||
static test_dump suite_test_dump;
|
||||
|
||||
static CxxTest::List Tests_test_dump = { 0, 0 };
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_dump( "/Users/thomas/Development/xlnt/tests/test_dump.hpp", 9, "test_dump", suite_test_dump, Tests_test_dump );
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_dump( "../../tests/test_dump.hpp", 9, "test_dump", suite_test_dump, Tests_test_dump );
|
||||
|
||||
static class TestDescription_suite_test_dump_test_dump_sheet_title : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_dump_test_dump_sheet_title() : CxxTest::RealTestDescription( Tests_test_dump, suiteDescription_test_dump, 17, "test_dump_sheet_title" ) {}
|
||||
TestDescription_suite_test_dump_test_dump_sheet_title() : CxxTest::RealTestDescription( Tests_test_dump, suiteDescription_test_dump, 12, "test_dump_sheet_title" ) {}
|
||||
void runTest() { suite_test_dump.test_dump_sheet_title(); }
|
||||
} testDescription_suite_test_dump_test_dump_sheet_title;
|
||||
|
||||
static class TestDescription_suite_test_dump_test_dump_sheet : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_dump_test_dump_sheet() : CxxTest::RealTestDescription( Tests_test_dump, suiteDescription_test_dump, 28, "test_dump_sheet" ) {}
|
||||
TestDescription_suite_test_dump_test_dump_sheet() : CxxTest::RealTestDescription( Tests_test_dump, suiteDescription_test_dump, 24, "test_dump_sheet" ) {}
|
||||
void runTest() { suite_test_dump.test_dump_sheet(); }
|
||||
} testDescription_suite_test_dump_test_dump_sheet;
|
||||
|
||||
static class TestDescription_suite_test_dump_test_table_builder : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_dump_test_table_builder() : CxxTest::RealTestDescription( Tests_test_dump, suiteDescription_test_dump, 120, "test_table_builder" ) {}
|
||||
TestDescription_suite_test_dump_test_table_builder() : CxxTest::RealTestDescription( Tests_test_dump, suiteDescription_test_dump, 116, "test_table_builder" ) {}
|
||||
void runTest() { suite_test_dump.test_table_builder(); }
|
||||
} testDescription_suite_test_dump_test_table_builder;
|
||||
|
||||
static class TestDescription_suite_test_dump_test_dump_twice : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_dump_test_dump_twice() : CxxTest::RealTestDescription( Tests_test_dump, suiteDescription_test_dump, 141, "test_dump_twice" ) {}
|
||||
TestDescription_suite_test_dump_test_dump_twice() : CxxTest::RealTestDescription( Tests_test_dump, suiteDescription_test_dump, 137, "test_dump_twice" ) {}
|
||||
void runTest() { suite_test_dump.test_dump_twice(); }
|
||||
} testDescription_suite_test_dump_test_dump_twice;
|
||||
|
||||
static class TestDescription_suite_test_dump_test_append_after_save : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_dump_test_append_after_save() : CxxTest::RealTestDescription( Tests_test_dump, suiteDescription_test_dump, 156, "test_append_after_save" ) {}
|
||||
TestDescription_suite_test_dump_test_append_after_save() : CxxTest::RealTestDescription( Tests_test_dump, suiteDescription_test_dump, 153, "test_append_after_save" ) {}
|
||||
void runTest() { suite_test_dump.test_append_after_save(); }
|
||||
} testDescription_suite_test_dump_test_append_after_save;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_named_range.hpp"
|
||||
#include "C:\Users\taf656\Development\xlnt\tests\test_named_range.hpp"
|
||||
|
||||
static test_named_range suite_test_named_range;
|
||||
|
||||
static CxxTest::List Tests_test_named_range = { 0, 0 };
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_named_range( "/Users/thomas/Development/xlnt/tests/test_named_range.hpp", 8, "test_named_range", suite_test_named_range, Tests_test_named_range );
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_named_range( "../../tests/test_named_range.hpp", 8, "test_named_range", suite_test_named_range, Tests_test_named_range );
|
||||
|
||||
static class TestDescription_suite_test_named_range_test_split : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
|
@ -403,12 +403,12 @@ public:
|
|||
void runTest() { suite_test_named_range.test_can_be_saved(); }
|
||||
} testDescription_suite_test_named_range_test_can_be_saved;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_number_format.hpp"
|
||||
#include "C:\Users\taf656\Development\xlnt\tests\test_number_format.hpp"
|
||||
|
||||
static test_number_format suite_test_number_format;
|
||||
|
||||
static CxxTest::List Tests_test_number_format = { 0, 0 };
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_number_format( "/Users/thomas/Development/xlnt/tests/test_number_format.hpp", 8, "test_number_format", suite_test_number_format, Tests_test_number_format );
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_number_format( "../../tests/test_number_format.hpp", 8, "test_number_format", suite_test_number_format, Tests_test_number_format );
|
||||
|
||||
static class TestDescription_suite_test_number_format_test_convert_date_to_julian : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
|
@ -506,12 +506,12 @@ public:
|
|||
void runTest() { suite_test_number_format.test_mac_date(); }
|
||||
} testDescription_suite_test_number_format_test_mac_date;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_props.hpp"
|
||||
#include "C:\Users\taf656\Development\xlnt\tests\test_props.hpp"
|
||||
|
||||
static test_props suite_test_props;
|
||||
|
||||
static CxxTest::List Tests_test_props = { 0, 0 };
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_props( "/Users/thomas/Development/xlnt/tests/test_props.hpp", 8, "test_props", suite_test_props, Tests_test_props );
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_props( "../../tests/test_props.hpp", 8, "test_props", suite_test_props, Tests_test_props );
|
||||
|
||||
static class TestDescription_suite_test_props_test_read_properties_core : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
|
@ -549,12 +549,12 @@ public:
|
|||
void runTest() { suite_test_props.test_write_properties_app(); }
|
||||
} testDescription_suite_test_props_test_write_properties_app;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_read.hpp"
|
||||
#include "C:\Users\taf656\Development\xlnt\tests\test_read.hpp"
|
||||
|
||||
static test_read suite_test_read;
|
||||
|
||||
static CxxTest::List Tests_test_read = { 0, 0 };
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_read( "/Users/thomas/Development/xlnt/tests/test_read.hpp", 10, "test_read", suite_test_read, Tests_test_read );
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_read( "../../tests/test_read.hpp", 10, "test_read", suite_test_read, Tests_test_read );
|
||||
|
||||
static class TestDescription_suite_test_read_test_read_standalone_worksheet : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
|
@ -682,12 +682,12 @@ public:
|
|||
void runTest() { suite_test_read.test_read_date_value(); }
|
||||
} testDescription_suite_test_read_test_read_date_value;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_strings.hpp"
|
||||
#include "C:\Users\taf656\Development\xlnt\tests\test_strings.hpp"
|
||||
|
||||
static test_strings suite_test_strings;
|
||||
|
||||
static CxxTest::List Tests_test_strings = { 0, 0 };
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_strings( "/Users/thomas/Development/xlnt/tests/test_strings.hpp", 8, "test_strings", suite_test_strings, Tests_test_strings );
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_strings( "../../tests/test_strings.hpp", 8, "test_strings", suite_test_strings, Tests_test_strings );
|
||||
|
||||
static class TestDescription_suite_test_strings_test_create_string_table : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
|
@ -713,12 +713,12 @@ public:
|
|||
void runTest() { suite_test_strings.test_formatted_string_table(); }
|
||||
} testDescription_suite_test_strings_test_formatted_string_table;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_style.hpp"
|
||||
#include "C:\Users\taf656\Development\xlnt\tests\test_style.hpp"
|
||||
|
||||
static test_style suite_test_style;
|
||||
|
||||
static CxxTest::List Tests_test_style = { 0, 0 };
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_style( "/Users/thomas/Development/xlnt/tests/test_style.hpp", 8, "test_style", suite_test_style, Tests_test_style );
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_style( "../../tests/test_style.hpp", 8, "test_style", suite_test_style, Tests_test_style );
|
||||
|
||||
static class TestDescription_suite_test_style_test_create_style_table : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
|
@ -810,25 +810,25 @@ public:
|
|||
void runTest() { suite_test_style.test_read_cell_style(); }
|
||||
} testDescription_suite_test_style_test_read_cell_style;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_theme.hpp"
|
||||
#include "C:\Users\taf656\Development\xlnt\tests\test_theme.hpp"
|
||||
|
||||
static test_theme suite_test_theme;
|
||||
|
||||
static CxxTest::List Tests_test_theme = { 0, 0 };
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_theme( "/Users/thomas/Development/xlnt/tests/test_theme.hpp", 9, "test_theme", suite_test_theme, Tests_test_theme );
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_theme( "../../tests/test_theme.hpp", 10, "test_theme", suite_test_theme, Tests_test_theme );
|
||||
|
||||
static class TestDescription_suite_test_theme_test_write_theme : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_theme_test_write_theme() : CxxTest::RealTestDescription( Tests_test_theme, suiteDescription_test_theme, 12, "test_write_theme" ) {}
|
||||
TestDescription_suite_test_theme_test_write_theme() : CxxTest::RealTestDescription( Tests_test_theme, suiteDescription_test_theme, 13, "test_write_theme" ) {}
|
||||
void runTest() { suite_test_theme.test_write_theme(); }
|
||||
} testDescription_suite_test_theme_test_write_theme;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_workbook.hpp"
|
||||
#include "C:\Users\taf656\Development\xlnt\tests\test_workbook.hpp"
|
||||
|
||||
static test_workbook suite_test_workbook;
|
||||
|
||||
static CxxTest::List Tests_test_workbook = { 0, 0 };
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_workbook( "/Users/thomas/Development/xlnt/tests/test_workbook.hpp", 9, "test_workbook", suite_test_workbook, Tests_test_workbook );
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_workbook( "../../tests/test_workbook.hpp", 9, "test_workbook", suite_test_workbook, Tests_test_workbook );
|
||||
|
||||
static class TestDescription_suite_test_workbook_test_get_active_sheet : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
|
@ -950,12 +950,12 @@ public:
|
|||
void runTest() { suite_test_workbook.test_write_regular_float(); }
|
||||
} testDescription_suite_test_workbook_test_write_regular_float;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_worksheet.hpp"
|
||||
#include "C:\Users\taf656\Development\xlnt\tests\test_worksheet.hpp"
|
||||
|
||||
static test_worksheet suite_test_worksheet;
|
||||
|
||||
static CxxTest::List Tests_test_worksheet = { 0, 0 };
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_worksheet( "/Users/thomas/Development/xlnt/tests/test_worksheet.hpp", 9, "test_worksheet", suite_test_worksheet, Tests_test_worksheet );
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_worksheet( "../../tests/test_worksheet.hpp", 9, "test_worksheet", suite_test_worksheet, Tests_test_worksheet );
|
||||
|
||||
static class TestDescription_suite_test_worksheet_test_new_worksheet : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
|
@ -1055,76 +1055,76 @@ public:
|
|||
|
||||
static class TestDescription_suite_test_worksheet_test_bad_relationship_type : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_worksheet_test_bad_relationship_type() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 168, "test_bad_relationship_type" ) {}
|
||||
TestDescription_suite_test_worksheet_test_bad_relationship_type() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 167, "test_bad_relationship_type" ) {}
|
||||
void runTest() { suite_test_worksheet.test_bad_relationship_type(); }
|
||||
} testDescription_suite_test_worksheet_test_bad_relationship_type;
|
||||
|
||||
static class TestDescription_suite_test_worksheet_test_append_list : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_worksheet_test_append_list() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 173, "test_append_list" ) {}
|
||||
TestDescription_suite_test_worksheet_test_append_list() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 172, "test_append_list" ) {}
|
||||
void runTest() { suite_test_worksheet.test_append_list(); }
|
||||
} testDescription_suite_test_worksheet_test_append_list;
|
||||
|
||||
static class TestDescription_suite_test_worksheet_test_append_dict_letter : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_worksheet_test_append_dict_letter() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 183, "test_append_dict_letter" ) {}
|
||||
TestDescription_suite_test_worksheet_test_append_dict_letter() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 182, "test_append_dict_letter" ) {}
|
||||
void runTest() { suite_test_worksheet.test_append_dict_letter(); }
|
||||
} testDescription_suite_test_worksheet_test_append_dict_letter;
|
||||
|
||||
static class TestDescription_suite_test_worksheet_test_append_dict_index : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_worksheet_test_append_dict_index() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 193, "test_append_dict_index" ) {}
|
||||
TestDescription_suite_test_worksheet_test_append_dict_index() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 192, "test_append_dict_index" ) {}
|
||||
void runTest() { suite_test_worksheet.test_append_dict_index(); }
|
||||
} testDescription_suite_test_worksheet_test_append_dict_index;
|
||||
|
||||
static class TestDescription_suite_test_worksheet_test_append_2d_list : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_worksheet_test_append_2d_list() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 203, "test_append_2d_list" ) {}
|
||||
TestDescription_suite_test_worksheet_test_append_2d_list() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 202, "test_append_2d_list" ) {}
|
||||
void runTest() { suite_test_worksheet.test_append_2d_list(); }
|
||||
} testDescription_suite_test_worksheet_test_append_2d_list;
|
||||
|
||||
static class TestDescription_suite_test_worksheet_test_rows : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_worksheet_test_rows() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 218, "test_rows" ) {}
|
||||
TestDescription_suite_test_worksheet_test_rows() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 217, "test_rows" ) {}
|
||||
void runTest() { suite_test_worksheet.test_rows(); }
|
||||
} testDescription_suite_test_worksheet_test_rows;
|
||||
|
||||
static class TestDescription_suite_test_worksheet_test_auto_filter : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_worksheet_test_auto_filter() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 233, "test_auto_filter" ) {}
|
||||
TestDescription_suite_test_worksheet_test_auto_filter() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 232, "test_auto_filter" ) {}
|
||||
void runTest() { suite_test_worksheet.test_auto_filter(); }
|
||||
} testDescription_suite_test_worksheet_test_auto_filter;
|
||||
|
||||
static class TestDescription_suite_test_worksheet_test_page_margins : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_worksheet_test_page_margins() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 247, "test_page_margins" ) {}
|
||||
TestDescription_suite_test_worksheet_test_page_margins() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 246, "test_page_margins" ) {}
|
||||
void runTest() { suite_test_worksheet.test_page_margins(); }
|
||||
} testDescription_suite_test_worksheet_test_page_margins;
|
||||
|
||||
static class TestDescription_suite_test_worksheet_test_merge : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_worksheet_test_merge() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 282, "test_merge" ) {}
|
||||
TestDescription_suite_test_worksheet_test_merge() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 292, "test_merge" ) {}
|
||||
void runTest() { suite_test_worksheet.test_merge(); }
|
||||
} testDescription_suite_test_worksheet_test_merge;
|
||||
|
||||
static class TestDescription_suite_test_worksheet_test_freeze : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_worksheet_test_freeze() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 351, "test_freeze" ) {}
|
||||
TestDescription_suite_test_worksheet_test_freeze() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 361, "test_freeze" ) {}
|
||||
void runTest() { suite_test_worksheet.test_freeze(); }
|
||||
} testDescription_suite_test_worksheet_test_freeze;
|
||||
|
||||
static class TestDescription_suite_test_worksheet_test_printer_settings : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_worksheet_test_printer_settings() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 368, "test_printer_settings" ) {}
|
||||
TestDescription_suite_test_worksheet_test_printer_settings() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 378, "test_printer_settings" ) {}
|
||||
void runTest() { suite_test_worksheet.test_printer_settings(); }
|
||||
} testDescription_suite_test_worksheet_test_printer_settings;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/test_write.hpp"
|
||||
#include "C:\Users\taf656\Development\xlnt\tests\test_write.hpp"
|
||||
|
||||
static test_write suite_test_write;
|
||||
|
||||
static CxxTest::List Tests_test_write = { 0, 0 };
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_write( "/Users/thomas/Development/xlnt/tests/test_write.hpp", 11, "test_write", suite_test_write, Tests_test_write );
|
||||
CxxTest::StaticSuiteDescription suiteDescription_test_write( "../../tests/test_write.hpp", 11, "test_write", suite_test_write, Tests_test_write );
|
||||
|
||||
static class TestDescription_suite_test_write_test_write_empty_workbook : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
|
@ -1140,79 +1140,79 @@ public:
|
|||
|
||||
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, 36, "test_write_workbook_rels" ) {}
|
||||
TestDescription_suite_test_write_test_write_workbook_rels() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 35, "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, 44, "test_write_workbook" ) {}
|
||||
TestDescription_suite_test_write_test_write_workbook() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 43, "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, 53, "test_write_string_table" ) {}
|
||||
TestDescription_suite_test_write_test_write_string_table() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 51, "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, 60, "test_write_worksheet" ) {}
|
||||
TestDescription_suite_test_write_test_write_worksheet() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 58, "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, 68, "test_write_hidden_worksheet" ) {}
|
||||
TestDescription_suite_test_write_test_write_hidden_worksheet() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 66, "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, 77, "test_write_bool" ) {}
|
||||
TestDescription_suite_test_write_test_write_bool() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 75, "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, 86, "test_write_formula" ) {}
|
||||
TestDescription_suite_test_write_test_write_formula() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 84, "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, 100, "test_write_style" ) {}
|
||||
TestDescription_suite_test_write_test_write_style() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 98, "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, 109, "test_write_height" ) {}
|
||||
TestDescription_suite_test_write_test_write_height() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 108, "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, 118, "test_write_hyperlink" ) {}
|
||||
TestDescription_suite_test_write_test_write_hyperlink() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 117, "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, 127, "test_write_hyperlink_rels" ) {}
|
||||
TestDescription_suite_test_write_test_write_hyperlink_rels() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 126, "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_hyperlink_value : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_test_write_test_hyperlink_value() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 141, "test_hyperlink_value" ) {}
|
||||
TestDescription_suite_test_write_test_hyperlink_value() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 140, "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, 150, "test_write_auto_filter" ) {}
|
||||
TestDescription_suite_test_write_test_write_auto_filter() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 149, "test_write_auto_filter" ) {}
|
||||
void runTest() { suite_test_write.test_write_auto_filter(); }
|
||||
} testDescription_suite_test_write_test_write_auto_filter;
|
||||
|
||||
|
|
|
@ -1,18 +1,18 @@
|
|||
<?xml version="1.0"?>
|
||||
<worksheet xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
|
||||
<worksheet xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
|
||||
<sheetPr>
|
||||
<outlinePr summaryRight="1" summaryBelow="1"/>
|
||||
<outlinePr summaryBelow="1" summaryRight="1" />
|
||||
</sheetPr>
|
||||
<dimension ref="A1:F42"/>
|
||||
<sheetViews>
|
||||
<sheetView workbookViewId="0">
|
||||
<selection sqref="A1" activeCell="A1"/>
|
||||
<selection activeCell="A1" sqref="A1" />
|
||||
</sheetView>
|
||||
</sheetViews>
|
||||
<sheetFormatPr baseColWidth="10" defaultRowHeight="15"/>
|
||||
<sheetFormatPr baseColWidth="10" defaultRowHeight="15" />
|
||||
<sheetData>
|
||||
<row spans="1:6" r="42">
|
||||
<c t="s" r="F42">
|
||||
<row r="42" spans="1:6">
|
||||
<c r="F42" t="s">
|
||||
<v>0</v>
|
||||
</c>
|
||||
</row>
|
||||
|
|
|
@ -9,13 +9,9 @@
|
|||
class test_dump : public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
test_dump() : wb(xlnt::optimization::write)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void test_dump_sheet_title()
|
||||
{
|
||||
xlnt::workbook wb(xlnt::optimization::write);
|
||||
auto ws = wb.create_sheet("Test1");
|
||||
wb.save(temp_file.GetFilename());
|
||||
xlnt::workbook wb2;
|
||||
|
@ -27,9 +23,8 @@ public:
|
|||
|
||||
void test_dump_sheet()
|
||||
{
|
||||
TS_SKIP("");
|
||||
auto test_filename = temp_file.GetFilename();
|
||||
auto ws = wb.create_sheet();
|
||||
xlnt::workbook wb(xlnt::optimization::write);
|
||||
auto ws = wb.create_sheet("test");
|
||||
|
||||
std::vector<std::string> letters;
|
||||
for(int i = 0; i < 20; i++)
|
||||
|
@ -39,80 +34,81 @@ public:
|
|||
|
||||
for(int row = 0; row < 20; row++)
|
||||
{
|
||||
std::vector<std::string> current_row;
|
||||
std::vector<std::string> current_row;
|
||||
for(auto letter : letters)
|
||||
{
|
||||
current_row.push_back(letter + std::to_string(row + 1));
|
||||
}
|
||||
ws.append(current_row);
|
||||
ws.append(current_row);
|
||||
}
|
||||
|
||||
for(int row = 0; row < 20; row++)
|
||||
{
|
||||
std::vector<int> current_row;
|
||||
std::vector<int> current_row;
|
||||
for(auto letter : letters)
|
||||
{
|
||||
current_row.push_back(row + 1);
|
||||
current_row.push_back(row + 21);
|
||||
}
|
||||
ws.append(current_row);
|
||||
ws.append(current_row);
|
||||
}
|
||||
|
||||
for(int row = 0; row < 10; row++)
|
||||
{
|
||||
std::vector<xlnt::date> current_row;
|
||||
std::vector<xlnt::date> current_row;
|
||||
for(std::size_t x = 0; x < letters.size(); x++)
|
||||
{
|
||||
current_row.push_back(xlnt::date(2010, (x % 12) + 1, row + 1));
|
||||
current_row.push_back(xlnt::date(2010, (x % 12) + 1, row + 1));
|
||||
}
|
||||
ws.append(current_row);
|
||||
ws.append(current_row);
|
||||
}
|
||||
|
||||
for(int row = 0; row < 20; row++)
|
||||
{
|
||||
std::vector<std::string> current_row;
|
||||
for(auto letter : letters)
|
||||
std::vector<std::string> current_row;
|
||||
for(auto letter : letters)
|
||||
{
|
||||
current_row.push_back("=" + letter + std::to_string(row + 1));
|
||||
current_row.push_back("=" + letter + std::to_string(row + 51));
|
||||
}
|
||||
ws.append(current_row);
|
||||
ws.append(current_row);
|
||||
}
|
||||
|
||||
auto test_filename = temp_file.GetFilename();
|
||||
wb.save(test_filename);
|
||||
|
||||
xlnt::workbook wb2;
|
||||
wb2.load(test_filename);
|
||||
ws = wb[2];
|
||||
ws = wb.get_sheet_by_name("test");
|
||||
|
||||
for(auto row : ws.rows())
|
||||
{
|
||||
for(auto cell : row)
|
||||
{
|
||||
auto row = cell.get_row();
|
||||
auto row = cell.get_row();
|
||||
|
||||
if(row <= 20)
|
||||
{
|
||||
std::string expected = cell.get_reference().to_string();
|
||||
TS_ASSERT_EQUALS(cell.get_data_type(), xlnt::cell::type::string);
|
||||
TS_ASSERT_EQUALS(cell, expected);
|
||||
}
|
||||
else if(row <= 40)
|
||||
{
|
||||
TS_ASSERT_EQUALS(cell.get_data_type(), xlnt::cell::type::numeric);
|
||||
TS_ASSERT_EQUALS(cell, (int)row);
|
||||
}
|
||||
else if(row <= 50)
|
||||
{
|
||||
xlnt::date expected(2010, (cell.get_reference().get_column_index() % 12) + 1, row + 1);
|
||||
TS_ASSERT_EQUALS(cell.get_data_type(), xlnt::cell::type::numeric);
|
||||
TS_ASSERT(cell.is_date());
|
||||
TS_ASSERT_EQUALS(cell, expected);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string expected = "=" + cell.get_reference().to_string();
|
||||
TS_ASSERT_EQUALS(cell.get_data_type(), xlnt::cell::type::formula);
|
||||
TS_ASSERT_EQUALS(cell, expected);
|
||||
}
|
||||
if(row <= 20)
|
||||
{
|
||||
std::string expected = cell.get_reference().to_string();
|
||||
TS_ASSERT_EQUALS(cell.get_data_type(), xlnt::cell::type::string);
|
||||
TS_ASSERT_EQUALS(cell, expected);
|
||||
}
|
||||
else if(row <= 40)
|
||||
{
|
||||
TS_ASSERT_EQUALS(cell.get_data_type(), xlnt::cell::type::numeric);
|
||||
TS_ASSERT_EQUALS(cell, (int)row);
|
||||
}
|
||||
else if(row <= 50)
|
||||
{
|
||||
xlnt::date expected(2010, (cell.get_reference().get_column_index() % 12) + 1, row + 1);
|
||||
TS_ASSERT_EQUALS(cell.get_data_type(), xlnt::cell::type::numeric);
|
||||
TS_ASSERT(cell.is_date());
|
||||
TS_ASSERT_EQUALS(cell, expected);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string expected = "=" + cell.get_reference().to_string();
|
||||
TS_ASSERT_EQUALS(cell.get_data_type(), xlnt::cell::type::formula);
|
||||
TS_ASSERT_EQUALS(cell, expected);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -140,6 +136,7 @@ public:
|
|||
|
||||
void test_dump_twice()
|
||||
{
|
||||
xlnt::workbook wb(xlnt::optimization::write);
|
||||
auto test_filename = temp_file.GetFilename();
|
||||
|
||||
auto ws = wb.create_sheet();
|
||||
|
@ -155,6 +152,7 @@ public:
|
|||
|
||||
void test_append_after_save()
|
||||
{
|
||||
xlnt::workbook wb(xlnt::optimization::write);
|
||||
auto ws = wb.create_sheet();
|
||||
|
||||
std::vector<std::string> to_append = {"hello"};
|
||||
|
@ -167,6 +165,5 @@ public:
|
|||
}
|
||||
|
||||
private:
|
||||
xlnt::workbook wb;
|
||||
TemporaryFile temp_file;
|
||||
};
|
||||
|
|
|
@ -5,21 +5,14 @@
|
|||
|
||||
#include <xlnt/xlnt.hpp>
|
||||
#include "helpers/path_helper.hpp"
|
||||
#include "helpers/helper.hpp"
|
||||
|
||||
class test_theme : public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
void test_write_theme()
|
||||
{
|
||||
TS_SKIP("");
|
||||
auto content = xlnt::writer::write_theme();
|
||||
|
||||
std::string comparison_file = PathHelper::GetDataDirectory() + "/writer/expected/theme1.xml";
|
||||
std::ifstream t(comparison_file);
|
||||
std::stringstream buffer;
|
||||
buffer << t.rdbuf();
|
||||
std::string expected = buffer.str();
|
||||
|
||||
TS_ASSERT_EQUALS(buffer.str(), content);
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/theme1.xml", content));
|
||||
}
|
||||
};
|
||||
|
|
|
@ -51,7 +51,7 @@ public:
|
|||
{
|
||||
xlnt::worksheet ws(wb);
|
||||
ws.get_cell("A1") = "AAA";
|
||||
TS_ASSERT_EQUALS("A1", ws.calculate_dimension().to_string());
|
||||
TS_ASSERT_EQUALS("A1:A1", ws.calculate_dimension().to_string());
|
||||
ws.get_cell("B12") = "AAA";
|
||||
TS_ASSERT_EQUALS("A1:B12", ws.calculate_dimension().to_string());
|
||||
}
|
||||
|
@ -147,21 +147,20 @@ public:
|
|||
void test_hyperlink_relationships()
|
||||
{
|
||||
xlnt::worksheet ws(wb);
|
||||
TS_SKIP("test_hyperlink_relationships");
|
||||
TS_ASSERT_EQUALS(ws.get_relationships().size(), 0);
|
||||
|
||||
ws.get_cell("A1").set_hyperlink("http:test.com");
|
||||
ws.get_cell("A1").set_hyperlink("http://test.com");
|
||||
TS_ASSERT_EQUALS(ws.get_relationships().size(), 1);
|
||||
TS_ASSERT_EQUALS("rId1", ws.get_cell("A1").get_hyperlink());
|
||||
TS_ASSERT_EQUALS("rId1", ws.get_cell("A1").get_hyperlink().get_id());
|
||||
TS_ASSERT_EQUALS("rId1", ws.get_relationships()[0].get_id());
|
||||
TS_ASSERT_EQUALS("http:test.com", ws.get_relationships()[0].get_target_uri());
|
||||
TS_ASSERT_EQUALS("http://test.com", ws.get_relationships()[0].get_target_uri());
|
||||
TS_ASSERT_EQUALS(xlnt::target_mode::external, ws.get_relationships()[0].get_target_mode());
|
||||
|
||||
ws.get_cell("A2").set_hyperlink("http:test2.com");
|
||||
ws.get_cell("A2").set_hyperlink("http://test2.com");
|
||||
TS_ASSERT_EQUALS(ws.get_relationships().size(), 2);
|
||||
TS_ASSERT_EQUALS("rId2", ws.get_cell("A2").get_hyperlink());
|
||||
TS_ASSERT_EQUALS("rId2", ws.get_cell("A2").get_hyperlink().get_id());
|
||||
TS_ASSERT_EQUALS("rId2", ws.get_relationships()[1].get_id());
|
||||
TS_ASSERT_EQUALS("http:test2.com", ws.get_relationships()[1].get_target_uri());
|
||||
TS_ASSERT_EQUALS("http://test2.com", ws.get_relationships()[1].get_target_uri());
|
||||
TS_ASSERT_EQUALS(xlnt::target_mode::external, ws.get_relationships()[1].get_target_mode());
|
||||
}
|
||||
|
||||
|
@ -276,7 +275,18 @@ public:
|
|||
xlnt::worksheet ws2(wb);
|
||||
xml_string = xlnt::writer::write_worksheet(ws2);
|
||||
doc.load(xml_string.c_str());
|
||||
TS_ASSERT_EQUALS(doc.child("worksheet").child("pageMargins"), nullptr);
|
||||
TS_ASSERT_DIFFERS(page_margins_node.attribute("left"), nullptr);
|
||||
TS_ASSERT_EQUALS(page_margins_node.attribute("left").as_double(), 0.75);
|
||||
TS_ASSERT_DIFFERS(page_margins_node.attribute("right"), nullptr);
|
||||
TS_ASSERT_EQUALS(page_margins_node.attribute("right").as_double(), 0.75);
|
||||
TS_ASSERT_DIFFERS(page_margins_node.attribute("top"), nullptr);
|
||||
TS_ASSERT_EQUALS(page_margins_node.attribute("top").as_double(), 1);
|
||||
TS_ASSERT_DIFFERS(page_margins_node.attribute("bottom"), nullptr);
|
||||
TS_ASSERT_EQUALS(page_margins_node.attribute("bottom").as_double(), 1);
|
||||
TS_ASSERT_DIFFERS(page_margins_node.attribute("header"), nullptr);
|
||||
TS_ASSERT_EQUALS(page_margins_node.attribute("header").as_double(), 0.5);
|
||||
TS_ASSERT_DIFFERS(page_margins_node.attribute("footer"), nullptr);
|
||||
TS_ASSERT_EQUALS(page_margins_node.attribute("footer").as_double(), 0.5);
|
||||
}
|
||||
|
||||
void test_merge()
|
||||
|
|
|
@ -14,9 +14,9 @@ public:
|
|||
void test_write_empty_workbook()
|
||||
{
|
||||
if(PathHelper::FileExists(temp_file.GetFilename()))
|
||||
{
|
||||
PathHelper::DeleteFile(temp_file.GetFilename());
|
||||
}
|
||||
{
|
||||
PathHelper::DeleteFile(temp_file.GetFilename());
|
||||
}
|
||||
|
||||
TS_ASSERT(!PathHelper::FileExists(temp_file.GetFilename()));
|
||||
wb.save(temp_file.GetFilename());
|
||||
|
@ -25,12 +25,11 @@ public:
|
|||
|
||||
void test_write_virtual_workbook()
|
||||
{
|
||||
TS_SKIP("");
|
||||
xlnt::workbook old_wb;
|
||||
std::vector<unsigned char> saved_wb;
|
||||
TS_ASSERT(old_wb.save(saved_wb));
|
||||
xlnt::workbook new_wb;
|
||||
TS_ASSERT(new_wb.load(saved_wb));
|
||||
std::vector<unsigned char> saved_wb;
|
||||
TS_ASSERT(old_wb.save(saved_wb));
|
||||
xlnt::workbook new_wb;
|
||||
TS_ASSERT(new_wb.load(saved_wb));
|
||||
}
|
||||
|
||||
void test_write_workbook_rels()
|
||||
|
@ -38,7 +37,7 @@ public:
|
|||
xlnt::workbook wb;
|
||||
auto content = xlnt::writer::write_workbook_rels(wb);
|
||||
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/workbook.xml.rels", content));
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/workbook.xml.rels", content));
|
||||
}
|
||||
|
||||
void test_write_workbook()
|
||||
|
@ -46,15 +45,14 @@ public:
|
|||
xlnt::workbook wb;
|
||||
auto content = xlnt::writer::write_workbook(wb);
|
||||
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/workbook.xml", content));
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/workbook.xml", content));
|
||||
}
|
||||
|
||||
|
||||
void test_write_string_table()
|
||||
{
|
||||
std::vector<std::string> table = {"hello", "world", "nice"};
|
||||
auto content = xlnt::writer::write_string_table(table);
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sharedStrings.xml", content));
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sharedStrings.xml", content));
|
||||
}
|
||||
|
||||
void test_write_worksheet()
|
||||
|
@ -62,7 +60,7 @@ public:
|
|||
auto ws = wb.create_sheet();
|
||||
ws.get_cell("F42") = "hello";
|
||||
auto content = xlnt::writer::write_worksheet(ws, {"hello"}, {});
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1.xml", content));
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1.xml", content));
|
||||
}
|
||||
|
||||
void test_write_hidden_worksheet()
|
||||
|
@ -71,7 +69,7 @@ public:
|
|||
ws.get_page_setup().set_sheet_state(xlnt::page_setup::sheet_state::hidden);
|
||||
ws.get_cell("F42") = "hello";
|
||||
auto content = xlnt::writer::write_worksheet(ws, {"hello"}, {});
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1.xml", content));
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1.xml", content));
|
||||
}
|
||||
|
||||
void test_write_bool()
|
||||
|
@ -94,16 +92,17 @@ public:
|
|||
ws.get_cell("B4") = "=";
|
||||
ws.get_cell("C4") = "=";
|
||||
auto content = xlnt::writer::write_worksheet(ws, {}, {});
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_formula.xml", content));
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_formula.xml", content));
|
||||
}
|
||||
|
||||
void test_write_style()
|
||||
{
|
||||
TS_SKIP("");
|
||||
auto ws = wb.create_sheet();
|
||||
ws.get_cell("F1") = "13%";
|
||||
auto style_id_by_hash = xlnt::style_writer(wb).get_style_by_hash();
|
||||
auto content = xlnt::writer::write_worksheet(ws, {}, style_id_by_hash);
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_style.xml", content));
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_style.xml", content));
|
||||
}
|
||||
|
||||
void test_write_height()
|
||||
|
@ -111,17 +110,17 @@ public:
|
|||
auto ws = wb.create_sheet();
|
||||
ws.get_cell("F1") = 10;
|
||||
ws.get_row_properties(ws.get_cell("F1").get_row()).set_height(30);
|
||||
auto content = xlnt::writer::write_worksheet(ws, {}, {});
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_height.xml", content));
|
||||
auto content = xlnt::writer::write_worksheet(ws, {}, {});
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_height.xml", content));
|
||||
}
|
||||
|
||||
void test_write_hyperlink()
|
||||
{
|
||||
auto ws = wb.create_sheet();
|
||||
ws.get_cell("A1") = "test";
|
||||
ws.get_cell("A1").set_hyperlink("http:test.com");
|
||||
auto content = xlnt::writer::write_worksheet(ws, {{"test", 0}}, {});
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_hyperlink.xml", content));
|
||||
ws.get_cell("A1").set_hyperlink("http://test.com");
|
||||
auto content = xlnt::writer::write_worksheet(ws, {"test"}, {});
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_hyperlink.xml", content));
|
||||
}
|
||||
|
||||
void test_write_hyperlink_rels()
|
||||
|
@ -129,13 +128,13 @@ public:
|
|||
auto ws = wb.create_sheet();
|
||||
TS_ASSERT_EQUALS(0, ws.get_relationships().size());
|
||||
ws.get_cell("A1") = "test";
|
||||
ws.get_cell("A1").set_hyperlink("http:test.com/");
|
||||
ws.get_cell("A1").set_hyperlink("http://test.com/");
|
||||
TS_ASSERT_EQUALS(1, ws.get_relationships().size());
|
||||
ws.get_cell("A2") = "test";
|
||||
ws.get_cell("A2").set_hyperlink("http:test2.com/");
|
||||
ws.get_cell("A2").set_hyperlink("http://test2.com/");
|
||||
TS_ASSERT_EQUALS(2, ws.get_relationships().size());
|
||||
auto content = xlnt::writer::write_worksheet_rels(ws, 1);
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_hyperlink.xml.rels", content));
|
||||
auto content = xlnt::writer::write_worksheet_rels(ws, 1, 1);
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_hyperlink.xml.rels", content));
|
||||
}
|
||||
|
||||
void test_hyperlink_value()
|
||||
|
@ -149,14 +148,15 @@ public:
|
|||
|
||||
void test_write_auto_filter()
|
||||
{
|
||||
auto ws = wb.create_sheet();
|
||||
xlnt::workbook wb;
|
||||
auto ws = wb.get_sheet_by_index(0);
|
||||
ws.get_cell("F42") = "hello";
|
||||
ws.auto_filter("A1:F1");
|
||||
auto content = xlnt::writer::write_worksheet(ws, {{"hello", 0}}, {});
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_auto_filter.xml", content));
|
||||
auto content = xlnt::writer::write_worksheet(ws, {"hello"}, {});
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_auto_filter.xml", content));
|
||||
|
||||
content = xlnt::writer::write_workbook(wb);
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/workbook_auto_filter.xml", content));
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/workbook_auto_filter.xml", content));
|
||||
}
|
||||
|
||||
void test_freeze_panes_horiz()
|
||||
|
@ -164,7 +164,7 @@ public:
|
|||
auto ws = wb.create_sheet();
|
||||
ws.get_cell("F42") = "hello";
|
||||
ws.freeze_panes("A4");
|
||||
auto content = xlnt::writer::write_worksheet(ws, {{"hello", 0}}, {});
|
||||
auto content = xlnt::writer::write_worksheet(ws, {"hello"}, {});
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_freeze_panes_horiz.xml", content));
|
||||
}
|
||||
|
||||
|
@ -173,8 +173,8 @@ public:
|
|||
auto ws = wb.create_sheet();
|
||||
ws.get_cell("F42") = "hello";
|
||||
ws.freeze_panes("D1");
|
||||
auto content = xlnt::writer::write_worksheet(ws, {{"hello", 0}}, {});
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_freeze_panes_vert.xml", content));
|
||||
auto content = xlnt::writer::write_worksheet(ws, {"hello"}, {});
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_freeze_panes_vert.xml", content));
|
||||
}
|
||||
|
||||
void test_freeze_panes_both()
|
||||
|
@ -182,8 +182,8 @@ public:
|
|||
auto ws = wb.create_sheet();
|
||||
ws.get_cell("F42") = "hello";
|
||||
ws.freeze_panes("D4");
|
||||
auto content = xlnt::writer::write_worksheet(ws, {{"hello", 0}}, {});
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_freeze_panes_both.xml", content));
|
||||
auto content = xlnt::writer::write_worksheet(ws, {"hello"}, {});
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/sheet1_freeze_panes_both.xml", content));
|
||||
}
|
||||
|
||||
void test_long_number()
|
||||
|
@ -191,7 +191,7 @@ public:
|
|||
auto ws = wb.create_sheet();
|
||||
ws.get_cell("A1") = 9781231231230;
|
||||
auto content = xlnt::writer::write_worksheet(ws, {}, {});
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/long_number.xml", content));
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/long_number.xml", content));
|
||||
}
|
||||
|
||||
void test_short_number()
|
||||
|
@ -199,7 +199,7 @@ public:
|
|||
auto ws = wb.create_sheet();
|
||||
ws.get_cell("A1") = 1234567890;
|
||||
auto content = xlnt::writer::write_worksheet(ws, {}, {});
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/short_number.xml", content));
|
||||
TS_ASSERT(Helper::EqualsFileContent(PathHelper::GetDataDirectory() + "/writer/expected/short_number.xml", content));
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue
Block a user