fix some things

This commit is contained in:
Thomas Fussell 2014-07-24 17:31:46 -04:00
parent bb064532ad
commit 24fbb75a9e
22 changed files with 689 additions and 275 deletions

View File

@ -77,7 +77,6 @@ public:
null, null,
numeric, numeric,
string, string,
formula,
boolean, boolean,
error error
}; };
@ -131,9 +130,12 @@ public:
void set_comment(comment &comment); void set_comment(comment &comment);
void set_comment(comment &&comment); void set_comment(comment &&comment);
void clear_comment(); void clear_comment();
bool has_comment() const;
std::string get_formula() const; std::string get_formula() const;
void set_formula(const std::string &formula); void set_formula(const std::string &formula);
void clear_formula();
bool has_formula() const;
std::string get_error() const; std::string get_error() const;
void set_error(const std::string &error); void set_error(const std::string &error);
@ -180,6 +182,8 @@ public:
friend bool operator==(const time &comparand, const cell &cell); friend bool operator==(const time &comparand, const cell &cell);
friend bool operator==(const datetime &comparand, const cell &cell); friend bool operator==(const datetime &comparand, const cell &cell);
friend bool operator<(cell left, cell right);
private: private:
friend class worksheet; friend class worksheet;
cell(detail::cell_impl *d); cell(detail::cell_impl *d);

View File

@ -101,6 +101,8 @@ public:
bool operator!=(const std::string &reference_string) const { return *this != cell_reference(reference_string); } bool operator!=(const std::string &reference_string) const { return *this != cell_reference(reference_string); }
bool operator!=(const char *reference_string) const { return *this != std::string(reference_string); } bool operator!=(const char *reference_string) const { return *this != std::string(reference_string); }
friend bool operator<(const cell_reference &left, const cell_reference &right);
private: private:
column_t column_index_; column_t column_index_;
row_t row_index_; row_t row_index_;

View File

@ -54,12 +54,14 @@ public:
hyperlink, hyperlink,
drawing, drawing,
worksheet, worksheet,
chartsheet,
shared_strings, shared_strings,
styles, styles,
theme, theme,
extended_properties, extended_properties,
core_properties, core_properties,
office_document office_document,
custom_xml
}; };
static type type_from_string(const std::string &type_string) static type type_from_string(const std::string &type_string)
@ -96,6 +98,14 @@ public:
{ {
return type::hyperlink; return type::hyperlink;
} }
else if(type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet")
{
return type::chartsheet;
}
else if(type_string == "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml")
{
return type::custom_xml;
}
return type::invalid; return type::invalid;
} }
@ -112,6 +122,8 @@ public:
case type::styles: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles"; case type::styles: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles";
case type::theme: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme"; case type::theme: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/theme";
case type::hyperlink: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink"; case type::hyperlink: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink";
case type::chartsheet: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/chartsheet";
case type::custom_xml: return "http://schemas.openxmlformats.org/officeDocument/2006/relationships/customXml";
default: return "??"; default: return "??";
} }
} }
@ -143,6 +155,15 @@ public:
type get_type() const { return type_; } type get_type() const { return type_; }
std::string get_type_string() const { return type_to_string(type_); } std::string get_type_string() const { return type_to_string(type_); }
friend bool operator==(const relationship &left, const relationship &right)
{
return left.type_ == right.type_
&& left.id_ == right.id_
&& left.source_uri_ == right.source_uri_
&& left.target_uri_ == right.target_uri_
&& left.target_mode_ == right.target_mode_;
}
private: private:
type type_; type type_;
std::string id_; std::string id_;

View File

@ -30,16 +30,20 @@
namespace xlnt { namespace xlnt {
class document_properties;
class relationship; class relationship;
class style;
class workbook; class workbook;
class worksheet; class worksheet;
class document_properties;
class zip_file; class zip_file;
class reader class reader
{ {
public: public:
static std::vector<relationship> read_relationships(const std::string &content); static const std::string CentralDirectorySignature;
static std::string repair_central_directory(const std::string &original);
static void fast_parse(worksheet ws, std::istream &xml_source, const std::vector<std::string> &shared_string, const std::vector<style> &style_table, std::size_t color_index);
static std::vector<relationship> read_relationships(const zip_file &content, const std::string &filename);
static std::vector<std::pair<std::string, std::string>> read_content_types(const zip_file &archive); static std::vector<std::pair<std::string, std::string>> read_content_types(const zip_file &archive);
static std::string determine_document_type(const std::vector<std::pair<std::string, std::string>> &override_types); static std::string determine_document_type(const std::vector<std::pair<std::string, std::string>> &override_types);
static worksheet read_worksheet(std::istream &handle, workbook &wb, const std::string &title, const std::vector<std::string> &string_table); static worksheet read_worksheet(std::istream &handle, workbook &wb, const std::string &title, const std::vector<std::string> &string_table);
@ -48,7 +52,8 @@ public:
static std::string read_dimension(const std::string &xml_string); static std::string read_dimension(const std::string &xml_string);
static document_properties read_properties_core(const std::string &xml_string); static document_properties read_properties_core(const std::string &xml_string);
static std::vector<std::pair<std::string,std::string>> read_sheets(const zip_file &archive); static std::vector<std::pair<std::string,std::string>> read_sheets(const zip_file &archive);
static workbook load_workbook(const std::string &filename, bool guess_types = false); static workbook load_workbook(const std::string &filename, bool guess_types = false, bool data_only = false);
static std::vector<std::pair<std::string, std::string>> detect_worksheets(const zip_file &archive);
}; };
} // namespace xlnt } // namespace xlnt

View File

@ -58,6 +58,41 @@ struct content_type
class workbook class workbook
{ {
public: public:
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); }
iterator operator++(int);
iterator &operator++();
private:
workbook &wb_;
std::size_t index_;
};
class const_iterator
{
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); }
const_iterator operator++(int);
const_iterator &operator++();
private:
const workbook &wb_;
std::size_t index_;
};
//constructors //constructors
workbook(); workbook();
@ -67,11 +102,13 @@ public:
friend void swap(workbook &left, workbook &right); friend void swap(workbook &left, workbook &right);
//getters
worksheet get_active_sheet(); worksheet get_active_sheet();
bool get_optimized_write() const;
bool get_guess_types() const; bool get_guess_types() const;
void set_guess_types(bool guess);
bool get_data_only() const; bool get_data_only() const;
void set_data_only(bool data_only);
//create //create
worksheet create_sheet(); worksheet create_sheet();
@ -98,43 +135,9 @@ public:
worksheet operator[](const std::string &name); worksheet operator[](const std::string &name);
worksheet operator[](std::size_t 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); }
iterator operator++(int);
iterator &operator++();
private:
workbook &wb_;
std::size_t index_;
};
iterator begin(); iterator begin();
iterator end(); iterator end();
class const_iterator
{
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); }
const_iterator operator++(int);
const_iterator &operator++();
private:
const workbook &wb_;
std::size_t index_;
};
const_iterator begin() const { return cbegin(); } const_iterator begin() const { return cbegin(); }
const_iterator end() const { return cend(); } const_iterator end() const { return cend(); }

View File

@ -316,6 +316,8 @@ public:
void set_parent(workbook &wb); void set_parent(workbook &wb);
std::vector<std::string> get_formula_attributes() const;
private: private:
friend class workbook; friend class workbook;
friend class cell; friend class cell;

View File

@ -91,8 +91,6 @@ std::string cell::get_internal_value_string() const
{ {
case type::string: case type::string:
return d_->string_value; return d_->string_value;
case type::formula:
return d_->string_value;
case type::error: case type::error:
return d_->string_value; return d_->string_value;
default: default:
@ -147,11 +145,7 @@ cell::type cell::data_type_for_value(const std::string &value)
return type::null; return type::null;
} }
if(value[0] == '=') if(value[0] == '0')
{
return type::formula;
}
else if(value[0] == '0')
{ {
if(value.length() > 1) if(value.length() > 1)
{ {
@ -225,24 +219,32 @@ void cell::set_explicit_value(const std::string &value, type data_type)
switch(data_type) switch(data_type)
{ {
case type::null: /*
if(value != "") case type::null:
{ if(value != "")
throw data_type_exception(); {
} throw data_type_exception();
return; }
case type::formula: return;
if(value.length() == 0 || value[0] != '=') case type::error: d_->string_value = value; return;
{ case type::boolean:
throw data_type_exception(); d_->numeric_value = value == "true";
} return;
d_->string_value = value; case type::numeric:
return; try
case type::error: d_->string_value = value; return; {
case type::boolean: d_->numeric_value = value == "true"; return; d_->numeric_value = std::stod(value);
case type::numeric: d_->numeric_value = std::stod(value); return; }
case type::string: d_->string_value = value; return; catch(std::invalid_argument)
default: throw std::runtime_error("bad enum"); {
throw data_type_exception();
}
return;
*/
case type::string:
d_->string_value = value;
return;
default: throw data_type_exception();
} }
} }
@ -253,7 +255,7 @@ void cell::set_explicit_value(int value, type data_type)
switch(data_type) switch(data_type)
{ {
case type::numeric: d_->numeric_value = value; return; case type::numeric: d_->numeric_value = value; return;
case type::string: d_->string_value = std::to_string(value); return; //case type::string: d_->string_value = std::to_string(value); return;
default: throw data_type_exception(); default: throw data_type_exception();
} }
} }
@ -265,7 +267,7 @@ void cell::set_explicit_value(double value, type data_type)
switch(data_type) switch(data_type)
{ {
case type::numeric: d_->numeric_value = value; return; case type::numeric: d_->numeric_value = value; return;
case type::string: d_->string_value = std::to_string(value); return; //case type::string: d_->string_value = std::to_string(value); return;
default: throw data_type_exception(); default: throw data_type_exception();
} }
} }
@ -297,7 +299,7 @@ bool cell::operator==(std::nullptr_t) const
bool cell::operator==(bool value) const bool cell::operator==(bool value) const
{ {
return d_->type_ == type::boolean && (bool)d_->numeric_value == value; return d_->type_ == type::boolean && (d_->numeric_value != 0) == value;
} }
bool cell::operator==(int comparand) const bool cell::operator==(int comparand) const
@ -312,10 +314,11 @@ bool cell::operator==(double comparand) const
bool cell::operator==(const std::string &comparand) const bool cell::operator==(const std::string &comparand) const
{ {
if(d_->type_ == type::string || d_->type_ == type::formula) if(d_->type_ == type::string)
{ {
return d_->string_value == comparand; return d_->string_value == comparand;
} }
return false; return false;
} }
@ -376,8 +379,6 @@ bool cell::operator==(const cell &comparand) const
return d_->string_value == comparand.d_->string_value; return d_->string_value == comparand.d_->string_value;
case type::string: case type::string:
return d_->string_value == comparand.d_->string_value; return d_->string_value == comparand.d_->string_value;
case type::formula:
return d_->string_value == comparand.d_->string_value;
case type::null: case type::null:
return true; return true;
case type::numeric: case type::numeric:
@ -505,32 +506,41 @@ cell &cell::operator=(bool value)
return *this; return *this;
} }
bool operator<(cell left, cell right)
{
return left.get_reference() < right.get_reference();
}
cell &cell::operator=(const std::string &value) cell &cell::operator=(const std::string &value)
{ {
d_->is_date_ = false; if(!get_parent().get_parent().get_guess_types())
d_->type_ = data_type_for_value(value);
switch((type)d_->type_)
{ {
case type::formula: d_->is_date_ = false;
d_->string_value = value; d_->type_ = type::string;
break; d_->string_value = value;
case type::numeric: }
if(value.find(':') != std::string::npos) else
{ {
d_->is_date_ = true; d_->is_date_ = false;
d_->numeric_value = time(value).to_number(); d_->type_ = data_type_for_value(value);
}
else if(value.back() == '%') switch(d_->type_)
{
d_->numeric_value = std::stod(value.substr(0, value.length() - 1)) / 100;
get_style().get_number_format().set_format_code(xlnt::number_format::format::percentage);
}
else
{ {
d_->numeric_value = std::stod(value); case type::numeric:
} if(value.find(':') != std::string::npos)
{
d_->is_date_ = true;
d_->numeric_value = time(value).to_number();
}
else if(value.back() == '%')
{
d_->numeric_value = std::stod(value.substr(0, value.length() - 1)) / 100;
get_style().get_number_format().set_format_code(xlnt::number_format::format::percentage);
}
else
{
d_->numeric_value = std::stod(value);
}
break; break;
case type::boolean: case type::boolean:
d_->numeric_value = value == "TRUE" || value == "true"; d_->numeric_value = value == "TRUE" || value == "true";
@ -543,8 +553,8 @@ cell &cell::operator=(const std::string &value)
break; break;
case type::null: case type::null:
break; break;
default: default: throw data_type_exception();
throw std::runtime_error("bad enum"); }
} }
return *this; return *this;
@ -632,13 +642,32 @@ void cell::set_null()
void cell::set_formula(const std::string &formula) void cell::set_formula(const std::string &formula)
{ {
if(formula.length() == 0 || formula[0] != '=') if(formula.length() == 0)
{ {
throw data_type_exception(); throw data_type_exception();
} }
d_->type_ = type::formula; d_->formula_value = formula;
d_->string_value = formula; }
bool cell::has_formula() const
{
return !d_->formula_value.empty();
}
std::string cell::get_formula() const
{
if(d_->formula_value.empty())
{
throw data_type_exception();
}
return d_->formula_value;
}
void cell::clear_formula()
{
d_->formula_value.clear();
} }
void cell::set_comment(xlnt::comment &c) void cell::set_comment(xlnt::comment &c)
@ -696,6 +725,11 @@ void cell::clear_comment()
d_->comment_.author_.clear(); d_->comment_.author_.clear();
} }
bool cell::has_comment() const
{
return d_->comment_.parent_worksheet_ != nullptr;
}
void cell::set_error(const std::string &error) void cell::set_error(const std::string &error)
{ {
if(error.length() == 0 || error[0] != '#') if(error.length() == 0 || error[0] != '#')

View File

@ -202,4 +202,14 @@ std::string cell_reference::column_string_from_index(column_t column_index)
return column_letter; return column_letter;
} }
bool operator<(const cell_reference &left, const cell_reference &right)
{
if(left.row_index_ != right.row_index_)
{
return left.row_index_ < right.row_index_;
}
return left.column_index_ < right.column_index_;
}
} }

View File

@ -24,6 +24,7 @@ struct cell_impl
cell::type type_; cell::type type_;
long double numeric_value; long double numeric_value;
std::string string_value; std::string string_value;
std::string formula_value;
relationship hyperlink_; relationship hyperlink_;
column_t column; column_t column;
row_t row; row_t row;

View File

@ -9,6 +9,7 @@ namespace detail {
struct workbook_impl struct workbook_impl
{ {
workbook_impl(); workbook_impl();
workbook_impl &operator=(const workbook_impl &other) workbook_impl &operator=(const workbook_impl &other)
{ {
active_sheet_index_ = other.active_sheet_index_; active_sheet_index_ = other.active_sheet_index_;
@ -19,12 +20,23 @@ struct workbook_impl
drawings_.clear(); drawings_.clear();
std::copy(other.drawings_.begin(), other.drawings_.end(), back_inserter(drawings_)); std::copy(other.drawings_.begin(), other.drawings_.end(), back_inserter(drawings_));
properties_ = other.properties_; properties_ = other.properties_;
guess_types_ = other.guess_types_;
data_only_ = other.data_only_;
return *this; return *this;
} }
workbook_impl(const workbook_impl &other) : active_sheet_index_(other.active_sheet_index_), worksheets_(other.worksheets_), relationships_(other.relationships_), drawings_(other.drawings_), properties_(other.properties_)
workbook_impl(const workbook_impl &other)
: active_sheet_index_(other.active_sheet_index_),
worksheets_(other.worksheets_),
relationships_(other.relationships_),
drawings_(other.drawings_),
properties_(other.properties_),
guess_types_(other.guess_types_),
data_only_(other.data_only_)
{ {
} }
//bool guess_types_; //bool guess_types_;
//bool data_only_; //bool data_only_;
int active_sheet_index_; int active_sheet_index_;
@ -32,6 +44,8 @@ struct workbook_impl
std::vector<relationship> relationships_; std::vector<relationship> relationships_;
std::vector<drawing> drawings_; std::vector<drawing> drawings_;
document_properties properties_; document_properties properties_;
bool guess_types_;
bool data_only_;
}; };
} // namespace detail } // namespace detail

View File

@ -1,3 +1,5 @@
#include <algorithm>
#include "styles/number_format.hpp" #include "styles/number_format.hpp"
namespace xlnt { namespace xlnt {
@ -71,11 +73,11 @@ const std::unordered_map<int, std::string> number_format::builtin_formats =
{39, "#,##0.00_);(#,##0.00)"}, {39, "#,##0.00_);(#,##0.00)"},
{40, "#,##0.00_);[Red](#,##0.00)"}, {40, "#,##0.00_);[Red](#,##0.00)"},
{41, "_(* #,##0_);_(* \(#,##0\\);_(* \"-\"_);_(@_)"}, {41, "_(* #,##0_);_(* \\(#,##0\\);_(* \"-\"_);_(@_)"},
{42, "_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"_);_(@_)"}, {42, "_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"_);_(@_)"},
{43, "_(* #,##0.00_);_(* \(#,##0.00\\);_(* \"-\"??_);_(@_)"}, {43, "_(* #,##0.00_);_(* \\(#,##0.00\\);_(* \"-\"??_);_(@_)"},
{44, "_(\"$\"* #,##0.00_)_(\"$\"* \(#,##0.00\\)_(\"$\"* \"-\"??_)_(@_)"}, {44, "_(\"$\"* #,##0.00_)_(\"$\"* \\(#,##0.00\\)_(\"$\"* \"-\"??_)_(@_)"},
{45, "mm:ss"}, {45, "mm:ss"},
{46, "[h]:mm:ss"}, {46, "[h]:mm:ss"},
{47, "mmss.0"}, {47, "mmss.0"},
@ -124,11 +126,11 @@ const std::unordered_map<std::string, int> number_format::reversed_builtin_forma
{"#,##0.00_);(#,##0.00)", 39}, {"#,##0.00_);(#,##0.00)", 39},
{"#,##0.00_);[Red](#,##0.00)", 40}, {"#,##0.00_);[Red](#,##0.00)", 40},
{"_(* #,##0_);_(* \(#,##0\\);_(* \"-\"_);_(@_)", 41}, {"_(* #,##0_);_(* \\(#,##0\\);_(* \"-\"_);_(@_)", 41},
{"_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"_);_(@_)", 42}, {"_(\"$\"* #,##0_);_(\"$\"* \\(#,##0\\);_(\"$\"* \"-\"_);_(@_)", 42},
{"_(* #,##0.00_);_(* \(#,##0.00\\);_(* \"-\"??_);_(@_)", 43}, {"_(* #,##0.00_);_(* \\(#,##0.00\\);_(* \"-\"??_);_(@_)", 43},
{"_(\"$\"* #,##0.00_)_(\"$\"* \(#,##0.00\\)_(\"$\"* \"-\"??_)_(@_)", 44}, {"_(\"$\"* #,##0.00_)_(\"$\"* \\(#,##0.00\\)_(\"$\"* \"-\"??_)_(@_)", 44},
{"mm:ss", 45}, {"mm:ss", 45},
{"[h]:mm:ss", 46}, {"[h]:mm:ss", 46},
{"mmss.0", 47}, {"mmss.0", 47},

View File

@ -183,7 +183,7 @@ cell cell_vector::get_cell(std::size_t index)
return ws_.get_cell(ref_.get_top_left().make_offset((int)index, 0)); return ws_.get_cell(ref_.get_top_left().make_offset((int)index, 0));
} }
return ws_.get_cell(ref_.get_top_left().make_offset(0, index)); return ws_.get_cell(ref_.get_top_left().make_offset(0, (int)index));
} }
range::range(worksheet ws, const range_reference &reference, major_order order) range::range(worksheet ws, const range_reference &reference, major_order order)

View File

@ -14,6 +14,37 @@
namespace xlnt { namespace xlnt {
const std::string reader::CentralDirectorySignature = "\x50\x4b\x05\x06";
std::string::size_type find_string_in_string(const std::string &string, const std::string &substring)
{
std::string::size_type possible_match_index = string.find(substring.at(0));
while(possible_match_index != std::string::npos)
{
if(string.substr(possible_match_index, substring.size()) == substring)
{
return possible_match_index;
}
possible_match_index = string.find(substring.at(0), possible_match_index + 1);
}
return possible_match_index;
}
std::string reader::repair_central_directory(const std::string &original)
{
auto pos = find_string_in_string(original, CentralDirectorySignature);
if(pos != std::string::npos)
{
return original.substr(0, pos + 22);
}
return original;
}
std::vector<std::pair<std::string, std::string>> reader::read_sheets(const zip_file &archive) std::vector<std::pair<std::string, std::string>> reader::read_sheets(const zip_file &archive)
{ {
auto xml_source = archive.get_file_contents("xl/workbook.xml"); auto xml_source = archive.get_file_contents("xl/workbook.xml");
@ -36,13 +67,21 @@ std::vector<std::pair<std::string, std::string>> reader::read_sheets(const zip_f
auto with_ns = [&](const std::string &base) { return ns.empty() ? base : ns + ":" + base; }; auto with_ns = [&](const std::string &base) { return ns.empty() ? base : ns + ":" + base; };
auto root_node = doc.child(with_ns("workbook").c_str());
auto sheets_node = root_node.child(with_ns("sheets").c_str());
std::vector<std::pair<std::string, std::string>> sheets; std::vector<std::pair<std::string, std::string>> sheets;
for(auto sheet_node : doc.child(with_ns("workbook").c_str()).child(with_ns("sheets").c_str()).children(with_ns("sheet").c_str()))
// store temp because pugixml iteration uses the internal char array multiple times
auto sheet_element_name = with_ns("sheet");
for(auto sheet_node : sheets_node.children(sheet_element_name.c_str()))
{ {
std::string id = sheet_node.attribute("r:id").as_string(); std::string id = sheet_node.attribute("r:id").as_string();
std::string name = sheet_node.attribute("name").as_string(); std::string name = sheet_node.attribute("name").as_string();
sheets.push_back(std::make_pair(id, name)); sheets.push_back(std::make_pair(id, name));
} }
return sheets; return sheets;
} }
@ -104,9 +143,15 @@ std::string reader::read_dimension(const std::string &xml_string)
return dimension; return dimension;
} }
std::vector<relationship> reader::read_relationships(const std::string &content) std::vector<relationship> reader::read_relationships(const zip_file &archive, const std::string &filename)
{ {
auto filename_separator_index = filename.find_last_of('/');
auto basename = filename.substr(filename_separator_index + 1);
auto dirname = filename.substr(0, filename_separator_index);
auto rels_filename = dirname + "/_rels/" + basename + ".rels";
pugi::xml_document doc; pugi::xml_document doc;
auto content = archive.get_file_contents(rels_filename);
doc.load(content.c_str()); doc.load(content.c_str());
auto root_node = doc.child("Relationships"); auto root_node = doc.child("Relationships");
@ -118,6 +163,17 @@ std::vector<relationship> reader::read_relationships(const std::string &content)
std::string id = relationship.attribute("Id").as_string(); std::string id = relationship.attribute("Id").as_string();
std::string type = relationship.attribute("Type").as_string(); std::string type = relationship.attribute("Type").as_string();
std::string target = relationship.attribute("Target").as_string(); std::string target = relationship.attribute("Target").as_string();
if(target[0] != '/' && target.substr(0, 2) != "..")
{
target = dirname + "/" + target;
}
if(target[0] == '/')
{
target = target.substr(1);
}
relationships.push_back(xlnt::relationship(type, id, target)); relationships.push_back(xlnt::relationship(type, id, target));
} }
@ -222,18 +278,28 @@ void read_worksheet_common(worksheet ws, const pugi::xml_node &root_node, const
if(cell_node != nullptr) if(cell_node != nullptr)
{ {
bool has_value = cell_node.child("v").text() != nullptr; bool has_value = cell_node.child("v") != nullptr;
std::string value = cell_node.child("v").text().as_string(); std::string value = cell_node.child("v").text().as_string();
bool has_type = cell_node.attribute("t") != nullptr; bool has_type = cell_node.attribute("t") != nullptr;
std::string type = cell_node.attribute("t").as_string(); std::string type = cell_node.attribute("t").as_string();
bool has_style = cell_node.attribute("s") != nullptr; bool has_style = cell_node.attribute("s") != nullptr;
std::string style = cell_node.attribute("s").as_string(); std::string style = cell_node.attribute("s").as_string();
bool has_formula = cell_node.child("f") != nullptr;
bool shared_formula = has_formula && cell_node.child("f").attribute("t") != nullptr && std::string(cell_node.child("f").attribute("t").as_string()) == "shared";
if(has_formula && !shared_formula && !ws.get_parent().get_data_only())
{
std::string formula = cell_node.child("f").text().as_string();
ws.get_cell(address).set_formula(formula);
}
if(has_type && type == "inlineStr") // inline string if(has_type && type == "inlineStr") // inline string
{ {
ws.get_cell(address) = cell_node.child("is").child("t").text().as_string(); std::string inline_string = cell_node.child("is").child("t").text().as_string();
ws.get_cell(address) = inline_string;
} }
else if(has_type && type == "s") // shared string else if(has_type && type == "s") // shared string
{ {
@ -243,6 +309,10 @@ void read_worksheet_common(worksheet ws, const pugi::xml_node &root_node, const
{ {
ws.get_cell(address) = value != "0"; ws.get_cell(address) = value != "0";
} }
else if(has_type && type == "str")
{
ws.get_cell(address) = value;
}
else if(has_style) else if(has_style)
{ {
auto number_format_id = number_format_ids.at(std::stoi(style)); auto number_format_id = number_format_ids.at(std::stoi(style));
@ -252,7 +322,14 @@ void read_worksheet_common(worksheet ws, const pugi::xml_node &root_node, const
} }
else if(has_value) else if(has_value)
{ {
ws.get_cell(address) = value; try
{
ws.get_cell(address) = std::stod(value);
}
catch(std::invalid_argument)
{
ws.get_cell(address) = value;
}
} }
} }
} }
@ -263,10 +340,17 @@ void read_worksheet_common(worksheet ws, const pugi::xml_node &root_node, const
if(auto_filter_node != nullptr) if(auto_filter_node != nullptr)
{ {
range_reference ref(auto_filter_node.attribute("ref").as_string()); range_reference ref(auto_filter_node.attribute("ref").as_string());
ws.auto_filter(ref); ws.auto_filter(ref);
} }
} }
void reader::fast_parse(worksheet ws, std::istream &xml_source, const std::vector<std::string> &shared_string, const std::vector<style> &/*style_table*/, std::size_t /*color_index*/)
{
pugi::xml_document doc;
doc.load(xml_source);
read_worksheet_common(ws, doc.child("worksheet"), shared_string, {});
}
void reader::read_worksheet(worksheet ws, const std::string &xml_string, const std::vector<std::string> &string_table, const std::vector<int> &number_format_ids) void reader::read_worksheet(worksheet ws, const std::string &xml_string, const std::vector<std::string> &string_table, const std::vector<int> &number_format_ids)
{ {
pugi::xml_document doc; pugi::xml_document doc;
@ -306,11 +390,45 @@ std::vector<std::string> reader::read_shared_string(const std::string &xml_strin
return shared_strings; return shared_strings;
} }
workbook reader::load_workbook(const std::string &filename, bool /*guess_types*/) workbook reader::load_workbook(const std::string &filename, bool guess_types, bool data_only)
{ {
workbook wb; workbook wb;
wb.set_guess_types(guess_types);
wb.set_data_only(data_only);
wb.load(filename); wb.load(filename);
return wb; return wb;
} }
std::vector<std::pair<std::string, std::string>> reader::detect_worksheets(const zip_file &archive)
{
static const std::string ValidWorksheet = "application/vnd.openxmlformats-officedocument.spreadsheetml.worksheet+xml";
auto content_types = read_content_types(archive);
std::vector<std::string> valid_sheets;
for(const auto &content_type : content_types)
{
if(content_type.second == ValidWorksheet)
{
valid_sheets.push_back(content_type.first);
}
}
auto workbook_relationships = reader::read_relationships(archive, "xl/workbook.xml");
std::vector<std::pair<std::string, std::string>> result;
for(const auto &ws : read_sheets(archive))
{
auto rel = *std::find_if(workbook_relationships.begin(), workbook_relationships.end(), [&](const relationship &r) { return r.get_id() == ws.first; });
auto target = rel.get_target_uri();
if(std::find(valid_sheets.begin(), valid_sheets.end(), "/" + target) != valid_sheets.end())
{
result.push_back({target, ws.second});
}
}
return result;
}
} // namespace xlnt } // namespace xlnt

View File

@ -2,7 +2,7 @@
namespace xlnt { namespace xlnt {
relationship::relationship(type t, const std::string &r_id, const std::string &target_uri) : type_(t), id_(r_id), source_uri_(""), target_uri_(target_uri) relationship::relationship(type t, const std::string &r_id, const std::string &target_uri) : type_(t), id_(r_id), source_uri_(""), target_uri_(target_uri), target_mode_(target_mode::internal)
{ {
if(t == type::hyperlink) if(t == type::hyperlink)
{ {
@ -10,7 +10,7 @@ relationship::relationship(type t, const std::string &r_id, const std::string &t
} }
} }
relationship::relationship() : type_(type::invalid), id_(""), source_uri_(""), target_uri_("") relationship::relationship() : type_(type::invalid), id_(""), source_uri_(""), target_uri_(""), target_mode_(target_mode::internal)
{ {
} }

View File

@ -44,10 +44,12 @@ static std::string CreateTemporaryFilename()
namespace xlnt { namespace xlnt {
namespace detail { namespace detail {
workbook_impl::workbook_impl() : active_sheet_index_(0)
workbook_impl::workbook_impl() : active_sheet_index_(0), guess_types_(false), data_only_(false)
{ {
} }
} // namespace detail } // namespace detail
workbook::workbook() : d_(new detail::workbook_impl()) workbook::workbook() : d_(new detail::workbook_impl())
@ -295,7 +297,7 @@ bool workbook::load(const std::string &filename)
clear(); clear();
auto workbook_relationships = reader::read_relationships(f.get_file_contents("xl/_rels/workbook.xml.rels")); auto workbook_relationships = reader::read_relationships(f, "xl/workbook.xml");
for(auto relationship : workbook_relationships) for(auto relationship : workbook_relationships)
{ {
@ -337,14 +339,23 @@ bool workbook::load(const std::string &filename)
{ {
std::string relation_id = sheet_node.attribute("r:id").as_string(); std::string relation_id = sheet_node.attribute("r:id").as_string();
auto ws = create_sheet(sheet_node.attribute("name").as_string()); auto ws = create_sheet(sheet_node.attribute("name").as_string());
std::string sheet_filename("xl/"); auto sheet_filename = get_relationship(relation_id).get_target_uri();
sheet_filename += get_relationship(relation_id).get_target_uri();
xlnt::reader::read_worksheet(ws, f.get_file_contents(sheet_filename).c_str(), shared_strings, number_format_ids); xlnt::reader::read_worksheet(ws, f.get_file_contents(sheet_filename).c_str(), shared_strings, number_format_ids);
} }
return true; return true;
} }
void workbook::set_guess_types(bool guess)
{
d_->guess_types_ = guess;
}
bool workbook::get_guess_types() const
{
return d_->guess_types_;
}
void workbook::create_relationship(const std::string &id, const std::string &target, relationship::type type) void workbook::create_relationship(const std::string &id, const std::string &target, relationship::type type)
{ {
d_->relationships_.push_back(relationship(type, id, target)); d_->relationships_.push_back(relationship(type, id, target));
@ -589,4 +600,14 @@ workbook::workbook(const workbook &other) : workbook()
} }
} }
bool workbook::get_data_only() const
{
return d_->data_only_;
}
void workbook::set_data_only(bool data_only)
{
d_->data_only_ = data_only;
}
} }

View File

@ -99,23 +99,30 @@ workbook &worksheet::get_parent() const
void worksheet::garbage_collect() void worksheet::garbage_collect()
{ {
auto cell_map_iter = d_->cell_map_.begin(); auto cell_map_iter = d_->cell_map_.begin();
while(cell_map_iter != d_->cell_map_.end()) while(cell_map_iter != d_->cell_map_.end())
{ {
auto cell_iter = cell_map_iter->second.begin(); auto cell_iter = cell_map_iter->second.begin();
while(cell_iter != cell_map_iter->second.end()) while(cell_iter != cell_map_iter->second.end())
{ {
if(cell(&cell_iter->second).get_data_type() == cell::type::null) cell current_cell(&cell_iter->second);
if(current_cell.get_data_type() == cell::type::null && !current_cell.has_comment())
{ {
cell_iter = cell_map_iter->second.erase(cell_iter); cell_iter = cell_map_iter->second.erase(cell_iter);
continue; continue;
} }
cell_iter++; cell_iter++;
} }
if(cell_map_iter->second.empty()) if(cell_map_iter->second.empty())
{ {
cell_map_iter = d_->cell_map_.erase(cell_map_iter); cell_map_iter = d_->cell_map_.erase(cell_map_iter);
continue; continue;
} }
cell_map_iter++; cell_map_iter++;
} }
} }
@ -546,4 +553,9 @@ void worksheet::set_parent(xlnt::workbook &wb)
d_->parent_ = &wb; d_->parent_ = &wb;
} }
std::vector<std::string> worksheet::get_formula_attributes() const
{
return {};
}
} // namespace xlnt } // namespace xlnt

View File

@ -313,7 +313,7 @@ std::string writer::write_worksheet(worksheet ws, const std::vector<std::string>
min = std::min(min, cell_reference::column_index_from_string(cell.get_column())); min = std::min(min, cell_reference::column_index_from_string(cell.get_column()));
max = std::max(max, cell_reference::column_index_from_string(cell.get_column())); max = std::max(max, cell_reference::column_index_from_string(cell.get_column()));
if(cell.get_data_type() != cell::type::null) if(cell.get_data_type() != cell::type::null || cell.is_merged() || cell.has_comment() || cell.has_formula())
{ {
any_non_null = true; any_non_null = true;
} }
@ -345,7 +345,7 @@ std::string writer::write_worksheet(worksheet ws, const std::vector<std::string>
for(auto cell : row) for(auto cell : row)
{ {
if(cell.get_data_type() != cell::type::null || cell.is_merged()) if(cell.get_data_type() != cell::type::null || cell.is_merged() || cell.has_comment() || cell.has_formula())
{ {
if(cell.has_hyperlink()) if(cell.has_hyperlink())
{ {
@ -357,6 +357,14 @@ std::string writer::write_worksheet(worksheet ws, const std::vector<std::string>
if(cell.get_data_type() == cell::type::string) if(cell.get_data_type() == cell::type::string)
{ {
if(cell.has_formula())
{
cell_node.append_attribute("t").set_value("str");
cell_node.append_child("f").text().set(cell.get_formula().c_str());
cell_node.append_child("v").text().set(cell.get_internal_value_string().c_str());
continue;
}
int match_index = -1; int match_index = -1;
for(int i = 0; i < (int)string_table.size(); i++) for(int i = 0; i < (int)string_table.size(); i++)
{ {
@ -392,6 +400,13 @@ std::string writer::write_worksheet(worksheet ws, const std::vector<std::string>
} }
else if(cell.get_data_type() == cell::type::numeric) else if(cell.get_data_type() == cell::type::numeric)
{ {
if(cell.has_formula())
{
cell_node.append_child("f").text().set(cell.get_formula().c_str());
cell_node.append_child("v").text().set(std::to_string(cell.get_internal_value_numeric()).c_str());
continue;
}
cell_node.append_attribute("t").set_value("n"); cell_node.append_attribute("t").set_value("n");
auto value_node = cell_node.append_child("v"); auto value_node = cell_node.append_child("v");
if(std::floor(cell.get_internal_value_numeric()) == cell.get_internal_value_numeric()) if(std::floor(cell.get_internal_value_numeric()) == cell.get_internal_value_numeric())
@ -403,11 +418,12 @@ std::string writer::write_worksheet(worksheet ws, const std::vector<std::string>
value_node.text().set((double)cell.get_internal_value_numeric()); value_node.text().set((double)cell.get_internal_value_numeric());
} }
} }
else if(cell.get_data_type() == cell::type::formula) }
{ else if(cell.has_formula())
cell_node.append_child("f").text().set(cell.get_internal_value_string().substr(1).c_str()); {
cell_node.append_child("v"); cell_node.append_child("f").text().set(cell.get_formula().c_str());
} cell_node.append_child("v");
continue;
} }
} }

View File

@ -21,7 +21,7 @@ int main( int argc, char *argv[] ) {
return status; return status;
} }
bool suite_test_cell_init = false; 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 test_cell suite_test_cell;
@ -108,97 +108,97 @@ public:
static class TestDescription_suite_test_cell_test_string : public CxxTest::RealTestDescription { static class TestDescription_suite_test_cell_test_string : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_cell_test_string() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 165, "test_string" ) {} TestDescription_suite_test_cell_test_string() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 167, "test_string" ) {}
void runTest() { suite_test_cell.test_string(); } void runTest() { suite_test_cell.test_string(); }
} testDescription_suite_test_cell_test_string; } testDescription_suite_test_cell_test_string;
static class TestDescription_suite_test_cell_test_single_dot : public CxxTest::RealTestDescription { static class TestDescription_suite_test_cell_test_single_dot : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_cell_test_single_dot() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 174, "test_single_dot" ) {} TestDescription_suite_test_cell_test_single_dot() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 176, "test_single_dot" ) {}
void runTest() { suite_test_cell.test_single_dot(); } void runTest() { suite_test_cell.test_single_dot(); }
} testDescription_suite_test_cell_test_single_dot; } testDescription_suite_test_cell_test_single_dot;
static class TestDescription_suite_test_cell_test_formula : public CxxTest::RealTestDescription { static class TestDescription_suite_test_cell_test_formula : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_cell_test_formula() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 182, "test_formula" ) {} TestDescription_suite_test_cell_test_formula() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 184, "test_formula" ) {}
void runTest() { suite_test_cell.test_formula(); } void runTest() { suite_test_cell.test_formula(); }
} testDescription_suite_test_cell_test_formula; } testDescription_suite_test_cell_test_formula;
static class TestDescription_suite_test_cell_test_boolean : public CxxTest::RealTestDescription { static class TestDescription_suite_test_cell_test_boolean : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_cell_test_boolean() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 192, "test_boolean" ) {} TestDescription_suite_test_cell_test_boolean() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 196, "test_boolean" ) {}
void runTest() { suite_test_cell.test_boolean(); } void runTest() { suite_test_cell.test_boolean(); }
} testDescription_suite_test_cell_test_boolean; } testDescription_suite_test_cell_test_boolean;
static class TestDescription_suite_test_cell_test_leading_zero : public CxxTest::RealTestDescription { static class TestDescription_suite_test_cell_test_leading_zero : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_cell_test_leading_zero() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 202, "test_leading_zero" ) {} TestDescription_suite_test_cell_test_leading_zero() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 206, "test_leading_zero" ) {}
void runTest() { suite_test_cell.test_leading_zero(); } void runTest() { suite_test_cell.test_leading_zero(); }
} testDescription_suite_test_cell_test_leading_zero; } testDescription_suite_test_cell_test_leading_zero;
static class TestDescription_suite_test_cell_test_error_codes : public CxxTest::RealTestDescription { static class TestDescription_suite_test_cell_test_error_codes : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_cell_test_error_codes() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 210, "test_error_codes" ) {} TestDescription_suite_test_cell_test_error_codes() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 214, "test_error_codes" ) {}
void runTest() { suite_test_cell.test_error_codes(); } void runTest() { suite_test_cell.test_error_codes(); }
} testDescription_suite_test_cell_test_error_codes; } testDescription_suite_test_cell_test_error_codes;
static class TestDescription_suite_test_cell_test_insert_float : public CxxTest::RealTestDescription { static class TestDescription_suite_test_cell_test_insert_float : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_cell_test_insert_float() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 222, "test_insert_float" ) {} TestDescription_suite_test_cell_test_insert_float() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 226, "test_insert_float" ) {}
void runTest() { suite_test_cell.test_insert_float(); } void runTest() { suite_test_cell.test_insert_float(); }
} testDescription_suite_test_cell_test_insert_float; } testDescription_suite_test_cell_test_insert_float;
static class TestDescription_suite_test_cell_test_insert_percentage : public CxxTest::RealTestDescription { static class TestDescription_suite_test_cell_test_insert_percentage : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_cell_test_insert_percentage() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 230, "test_insert_percentage" ) {} TestDescription_suite_test_cell_test_insert_percentage() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 234, "test_insert_percentage" ) {}
void runTest() { suite_test_cell.test_insert_percentage(); } void runTest() { suite_test_cell.test_insert_percentage(); }
} testDescription_suite_test_cell_test_insert_percentage; } testDescription_suite_test_cell_test_insert_percentage;
static class TestDescription_suite_test_cell_test_insert_datetime : public CxxTest::RealTestDescription { static class TestDescription_suite_test_cell_test_insert_datetime : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_cell_test_insert_datetime() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 238, "test_insert_datetime" ) {} TestDescription_suite_test_cell_test_insert_datetime() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 242, "test_insert_datetime" ) {}
void runTest() { suite_test_cell.test_insert_datetime(); } void runTest() { suite_test_cell.test_insert_datetime(); }
} testDescription_suite_test_cell_test_insert_datetime; } testDescription_suite_test_cell_test_insert_datetime;
static class TestDescription_suite_test_cell_test_insert_date : public CxxTest::RealTestDescription { static class TestDescription_suite_test_cell_test_insert_date : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_cell_test_insert_date() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 246, "test_insert_date" ) {} TestDescription_suite_test_cell_test_insert_date() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 250, "test_insert_date" ) {}
void runTest() { suite_test_cell.test_insert_date(); } void runTest() { suite_test_cell.test_insert_date(); }
} testDescription_suite_test_cell_test_insert_date; } testDescription_suite_test_cell_test_insert_date;
static class TestDescription_suite_test_cell_test_internal_date : public CxxTest::RealTestDescription { static class TestDescription_suite_test_cell_test_internal_date : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_cell_test_internal_date() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 254, "test_internal_date" ) {} TestDescription_suite_test_cell_test_internal_date() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 258, "test_internal_date" ) {}
void runTest() { suite_test_cell.test_internal_date(); } void runTest() { suite_test_cell.test_internal_date(); }
} testDescription_suite_test_cell_test_internal_date; } testDescription_suite_test_cell_test_internal_date;
static class TestDescription_suite_test_cell_test_datetime_interpretation : public CxxTest::RealTestDescription { static class TestDescription_suite_test_cell_test_datetime_interpretation : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_cell_test_datetime_interpretation() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 263, "test_datetime_interpretation" ) {} TestDescription_suite_test_cell_test_datetime_interpretation() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 267, "test_datetime_interpretation" ) {}
void runTest() { suite_test_cell.test_datetime_interpretation(); } void runTest() { suite_test_cell.test_datetime_interpretation(); }
} testDescription_suite_test_cell_test_datetime_interpretation; } testDescription_suite_test_cell_test_datetime_interpretation;
static class TestDescription_suite_test_cell_test_date_interpretation : public CxxTest::RealTestDescription { static class TestDescription_suite_test_cell_test_date_interpretation : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_cell_test_date_interpretation() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 273, "test_date_interpretation" ) {} TestDescription_suite_test_cell_test_date_interpretation() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 277, "test_date_interpretation" ) {}
void runTest() { suite_test_cell.test_date_interpretation(); } void runTest() { suite_test_cell.test_date_interpretation(); }
} testDescription_suite_test_cell_test_date_interpretation; } testDescription_suite_test_cell_test_date_interpretation;
static class TestDescription_suite_test_cell_test_number_format_style : public CxxTest::RealTestDescription { static class TestDescription_suite_test_cell_test_number_format_style : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_cell_test_number_format_style() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 283, "test_number_format_style" ) {} TestDescription_suite_test_cell_test_number_format_style() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 287, "test_number_format_style" ) {}
void runTest() { suite_test_cell.test_number_format_style(); } void runTest() { suite_test_cell.test_number_format_style(); }
} testDescription_suite_test_cell_test_number_format_style; } testDescription_suite_test_cell_test_number_format_style;
static class TestDescription_suite_test_cell_test_data_type_check : public CxxTest::RealTestDescription { static class TestDescription_suite_test_cell_test_data_type_check : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_cell_test_data_type_check() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 291, "test_data_type_check" ) {} TestDescription_suite_test_cell_test_data_type_check() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 295, "test_data_type_check" ) {}
void runTest() { suite_test_cell.test_data_type_check(); } void runTest() { suite_test_cell.test_data_type_check(); }
} testDescription_suite_test_cell_test_data_type_check; } testDescription_suite_test_cell_test_data_type_check;
static class TestDescription_suite_test_cell_test_set_bad_type : public CxxTest::RealTestDescription { static class TestDescription_suite_test_cell_test_set_bad_type : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_cell_test_set_bad_type() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 308, "test_set_bad_type" ) {} TestDescription_suite_test_cell_test_set_bad_type() : CxxTest::RealTestDescription( Tests_test_cell, suiteDescription_test_cell, 312, "test_set_bad_type" ) {}
void runTest() { suite_test_cell.test_set_bad_type(); } void runTest() { suite_test_cell.test_set_bad_type(); }
} testDescription_suite_test_cell_test_set_bad_type; } testDescription_suite_test_cell_test_set_bad_type;
@ -262,7 +262,7 @@ public:
void runTest() { suite_test_cell.test_cell_offset(); } void runTest() { suite_test_cell.test_cell_offset(); }
} testDescription_suite_test_cell_test_cell_offset; } testDescription_suite_test_cell_test_cell_offset;
#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 test_chart suite_test_chart;
@ -353,7 +353,7 @@ public:
void runTest() { suite_test_chart.test_write_chart_scatter(); } void runTest() { suite_test_chart.test_write_chart_scatter(); }
} testDescription_suite_test_chart_test_write_chart_scatter; } testDescription_suite_test_chart_test_write_chart_scatter;
#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 test_named_range suite_test_named_range;
@ -444,7 +444,7 @@ public:
void runTest() { suite_test_named_range.test_can_be_saved(); } void runTest() { suite_test_named_range.test_can_be_saved(); }
} testDescription_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 test_number_format suite_test_number_format;
@ -547,7 +547,7 @@ public:
void runTest() { suite_test_number_format.test_mac_date(); } void runTest() { suite_test_number_format.test_mac_date(); }
} testDescription_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 test_props suite_test_props;
@ -590,7 +590,7 @@ public:
void runTest() { suite_test_props.test_write_properties_app(); } void runTest() { suite_test_props.test_write_properties_app(); }
} testDescription_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 test_read suite_test_read;
@ -713,83 +713,83 @@ public:
static class TestDescription_suite_test_read_test_read_no_theme : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_read_no_theme : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_read_no_theme() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 202, "test_read_no_theme" ) {} TestDescription_suite_test_read_test_read_no_theme() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 199, "test_read_no_theme" ) {}
void runTest() { suite_test_read.test_read_no_theme(); } void runTest() { suite_test_read.test_read_no_theme(); }
} testDescription_suite_test_read_test_read_no_theme; } testDescription_suite_test_read_test_read_no_theme;
static class TestDescription_suite_test_read_test_read_cell_formulae : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_read_cell_formulae : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_read_cell_formulae() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 209, "test_read_cell_formulae" ) {} TestDescription_suite_test_read_test_read_cell_formulae() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 206, "test_read_cell_formulae" ) {}
void runTest() { suite_test_read.test_read_cell_formulae(); } void runTest() { suite_test_read.test_read_cell_formulae(); }
} testDescription_suite_test_read_test_read_cell_formulae; } testDescription_suite_test_read_test_read_cell_formulae;
static class TestDescription_suite_test_read_test_read_complex_formulae : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_read_complex_formulae : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_read_complex_formulae() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 229, "test_read_complex_formulae" ) {} TestDescription_suite_test_read_test_read_complex_formulae() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 223, "test_read_complex_formulae" ) {}
void runTest() { suite_test_read.test_read_complex_formulae(); } void runTest() { suite_test_read.test_read_complex_formulae(); }
} testDescription_suite_test_read_test_read_complex_formulae; } testDescription_suite_test_read_test_read_complex_formulae;
static class TestDescription_suite_test_read_test_data_only : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_data_only : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_data_only() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 234, "test_data_only" ) {} TestDescription_suite_test_read_test_data_only() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 282, "test_data_only" ) {}
void runTest() { suite_test_read.test_data_only(); } void runTest() { suite_test_read.test_data_only(); }
} testDescription_suite_test_read_test_data_only; } testDescription_suite_test_read_test_data_only;
static class TestDescription_suite_test_read_test_detect_worksheets : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_detect_worksheets : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_detect_worksheets() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 239, "test_detect_worksheets" ) {} TestDescription_suite_test_read_test_detect_worksheets() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 304, "test_detect_worksheets" ) {}
void runTest() { suite_test_read.test_detect_worksheets(); } void runTest() { suite_test_read.test_detect_worksheets(); }
} testDescription_suite_test_read_test_detect_worksheets; } testDescription_suite_test_read_test_detect_worksheets;
static class TestDescription_suite_test_read_test_read_rels : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_read_rels : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_read_rels() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 244, "test_read_rels" ) {} TestDescription_suite_test_read_test_read_rels() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 344, "test_read_rels" ) {}
void runTest() { suite_test_read.test_read_rels(); } void runTest() { suite_test_read.test_read_rels(); }
} testDescription_suite_test_read_test_read_rels; } testDescription_suite_test_read_test_read_rels;
static class TestDescription_suite_test_read_test_read_content_types : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_read_content_types : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_read_content_types() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 249, "test_read_content_types" ) {} TestDescription_suite_test_read_test_read_content_types() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 382, "test_read_content_types" ) {}
void runTest() { suite_test_read.test_read_content_types(); } void runTest() { suite_test_read.test_read_content_types(); }
} testDescription_suite_test_read_test_read_content_types; } testDescription_suite_test_read_test_read_content_types;
static class TestDescription_suite_test_read_test_read_sheets : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_read_sheets : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_read_sheets() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 285, "test_read_sheets" ) {} TestDescription_suite_test_read_test_read_sheets() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 418, "test_read_sheets" ) {}
void runTest() { suite_test_read.test_read_sheets(); } void runTest() { suite_test_read.test_read_sheets(); }
} testDescription_suite_test_read_test_read_sheets; } testDescription_suite_test_read_test_read_sheets;
static class TestDescription_suite_test_read_test_guess_types : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_guess_types : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_guess_types() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 306, "test_guess_types" ) {} TestDescription_suite_test_read_test_guess_types() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 439, "test_guess_types" ) {}
void runTest() { suite_test_read.test_guess_types(); } void runTest() { suite_test_read.test_guess_types(); }
} testDescription_suite_test_read_test_guess_types; } testDescription_suite_test_read_test_guess_types;
static class TestDescription_suite_test_read_test_read_autofilter : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_read_autofilter : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_read_autofilter() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 323, "test_read_autofilter" ) {} TestDescription_suite_test_read_test_read_autofilter() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 455, "test_read_autofilter" ) {}
void runTest() { suite_test_read.test_read_autofilter(); } void runTest() { suite_test_read.test_read_autofilter(); }
} testDescription_suite_test_read_test_read_autofilter; } testDescription_suite_test_read_test_read_autofilter;
static class TestDescription_suite_test_read_test_bad_formats_xlsb : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_bad_formats_xlsb : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_bad_formats_xlsb() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 331, "test_bad_formats_xlsb" ) {} TestDescription_suite_test_read_test_bad_formats_xlsb() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 463, "test_bad_formats_xlsb" ) {}
void runTest() { suite_test_read.test_bad_formats_xlsb(); } void runTest() { suite_test_read.test_bad_formats_xlsb(); }
} testDescription_suite_test_read_test_bad_formats_xlsb; } testDescription_suite_test_read_test_bad_formats_xlsb;
static class TestDescription_suite_test_read_test_bad_formats_xls : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_bad_formats_xls : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_bad_formats_xls() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 337, "test_bad_formats_xls" ) {} TestDescription_suite_test_read_test_bad_formats_xls() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 469, "test_bad_formats_xls" ) {}
void runTest() { suite_test_read.test_bad_formats_xls(); } void runTest() { suite_test_read.test_bad_formats_xls(); }
} testDescription_suite_test_read_test_bad_formats_xls; } testDescription_suite_test_read_test_bad_formats_xls;
static class TestDescription_suite_test_read_test_bad_formats_no : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_bad_formats_no : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_bad_formats_no() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 343, "test_bad_formats_no" ) {} TestDescription_suite_test_read_test_bad_formats_no() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 475, "test_bad_formats_no" ) {}
void runTest() { suite_test_read.test_bad_formats_no(); } void runTest() { suite_test_read.test_bad_formats_no(); }
} testDescription_suite_test_read_test_bad_formats_no; } testDescription_suite_test_read_test_bad_formats_no;
#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 test_strings suite_test_strings;
@ -820,7 +820,7 @@ public:
void runTest() { suite_test_strings.test_formatted_string_table(); } void runTest() { suite_test_strings.test_formatted_string_table(); }
} testDescription_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 test_style suite_test_style;
@ -917,7 +917,7 @@ public:
void runTest() { suite_test_style.test_read_cell_style(); } void runTest() { suite_test_style.test_read_cell_style(); }
} testDescription_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 test_theme suite_test_theme;
@ -930,7 +930,7 @@ public:
void runTest() { suite_test_theme.test_write_theme(); } void runTest() { suite_test_theme.test_write_theme(); }
} testDescription_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 test_workbook suite_test_workbook;
@ -1051,7 +1051,7 @@ public:
void runTest() { suite_test_workbook.test_write_regular_float(); } void runTest() { suite_test_workbook.test_write_regular_float(); }
} testDescription_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 test_worksheet suite_test_worksheet;
@ -1156,119 +1156,119 @@ public:
static class TestDescription_suite_test_worksheet_test_hyperlink_relationships : public CxxTest::RealTestDescription { static class TestDescription_suite_test_worksheet_test_hyperlink_relationships : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_hyperlink_relationships() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 153, "test_hyperlink_relationships" ) {} TestDescription_suite_test_worksheet_test_hyperlink_relationships() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 168, "test_hyperlink_relationships" ) {}
void runTest() { suite_test_worksheet.test_hyperlink_relationships(); } void runTest() { suite_test_worksheet.test_hyperlink_relationships(); }
} testDescription_suite_test_worksheet_test_hyperlink_relationships; } testDescription_suite_test_worksheet_test_hyperlink_relationships;
static class TestDescription_suite_test_worksheet_test_bad_relationship_type : public CxxTest::RealTestDescription { static class TestDescription_suite_test_worksheet_test_bad_relationship_type : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_bad_relationship_type() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 173, "test_bad_relationship_type" ) {} TestDescription_suite_test_worksheet_test_bad_relationship_type() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 188, "test_bad_relationship_type" ) {}
void runTest() { suite_test_worksheet.test_bad_relationship_type(); } void runTest() { suite_test_worksheet.test_bad_relationship_type(); }
} testDescription_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 { static class TestDescription_suite_test_worksheet_test_append_list : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_append_list() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 178, "test_append_list" ) {} TestDescription_suite_test_worksheet_test_append_list() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 193, "test_append_list" ) {}
void runTest() { suite_test_worksheet.test_append_list(); } void runTest() { suite_test_worksheet.test_append_list(); }
} testDescription_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 { static class TestDescription_suite_test_worksheet_test_append_dict_letter : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_append_dict_letter() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 188, "test_append_dict_letter" ) {} TestDescription_suite_test_worksheet_test_append_dict_letter() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 203, "test_append_dict_letter" ) {}
void runTest() { suite_test_worksheet.test_append_dict_letter(); } void runTest() { suite_test_worksheet.test_append_dict_letter(); }
} testDescription_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 { static class TestDescription_suite_test_worksheet_test_append_dict_index : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_append_dict_index() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 198, "test_append_dict_index" ) {} TestDescription_suite_test_worksheet_test_append_dict_index() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 213, "test_append_dict_index" ) {}
void runTest() { suite_test_worksheet.test_append_dict_index(); } void runTest() { suite_test_worksheet.test_append_dict_index(); }
} testDescription_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 { static class TestDescription_suite_test_worksheet_test_append_2d_list : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_append_2d_list() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 208, "test_append_2d_list" ) {} TestDescription_suite_test_worksheet_test_append_2d_list() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 223, "test_append_2d_list" ) {}
void runTest() { suite_test_worksheet.test_append_2d_list(); } void runTest() { suite_test_worksheet.test_append_2d_list(); }
} testDescription_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 { static class TestDescription_suite_test_worksheet_test_rows : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_rows() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 223, "test_rows" ) {} TestDescription_suite_test_worksheet_test_rows() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 238, "test_rows" ) {}
void runTest() { suite_test_worksheet.test_rows(); } void runTest() { suite_test_worksheet.test_rows(); }
} testDescription_suite_test_worksheet_test_rows; } testDescription_suite_test_worksheet_test_rows;
static class TestDescription_suite_test_worksheet_test_cols : public CxxTest::RealTestDescription { static class TestDescription_suite_test_worksheet_test_cols : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_cols() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 238, "test_cols" ) {} TestDescription_suite_test_worksheet_test_cols() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 253, "test_cols" ) {}
void runTest() { suite_test_worksheet.test_cols(); } void runTest() { suite_test_worksheet.test_cols(); }
} testDescription_suite_test_worksheet_test_cols; } testDescription_suite_test_worksheet_test_cols;
static class TestDescription_suite_test_worksheet_test_auto_filter : public CxxTest::RealTestDescription { static class TestDescription_suite_test_worksheet_test_auto_filter : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_auto_filter() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 253, "test_auto_filter" ) {} TestDescription_suite_test_worksheet_test_auto_filter() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 268, "test_auto_filter" ) {}
void runTest() { suite_test_worksheet.test_auto_filter(); } void runTest() { suite_test_worksheet.test_auto_filter(); }
} testDescription_suite_test_worksheet_test_auto_filter; } testDescription_suite_test_worksheet_test_auto_filter;
static class TestDescription_suite_test_worksheet_test_freeze : public CxxTest::RealTestDescription { static class TestDescription_suite_test_worksheet_test_freeze : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_freeze() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 267, "test_freeze" ) {} TestDescription_suite_test_worksheet_test_freeze() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 282, "test_freeze" ) {}
void runTest() { suite_test_worksheet.test_freeze(); } void runTest() { suite_test_worksheet.test_freeze(); }
} testDescription_suite_test_worksheet_test_freeze; } testDescription_suite_test_worksheet_test_freeze;
static class TestDescription_suite_test_worksheet_test_write_empty : public CxxTest::RealTestDescription { static class TestDescription_suite_test_worksheet_test_write_empty : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_write_empty() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 284, "test_write_empty" ) {} TestDescription_suite_test_worksheet_test_write_empty() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 299, "test_write_empty" ) {}
void runTest() { suite_test_worksheet.test_write_empty(); } void runTest() { suite_test_worksheet.test_write_empty(); }
} testDescription_suite_test_worksheet_test_write_empty; } testDescription_suite_test_worksheet_test_write_empty;
static class TestDescription_suite_test_worksheet_test_page_margins : public CxxTest::RealTestDescription { static class TestDescription_suite_test_worksheet_test_page_margins : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_page_margins() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 296, "test_page_margins" ) {} TestDescription_suite_test_worksheet_test_page_margins() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 311, "test_page_margins" ) {}
void runTest() { suite_test_worksheet.test_page_margins(); } void runTest() { suite_test_worksheet.test_page_margins(); }
} testDescription_suite_test_worksheet_test_page_margins; } testDescription_suite_test_worksheet_test_page_margins;
static class TestDescription_suite_test_worksheet_test_merge : public CxxTest::RealTestDescription { static class TestDescription_suite_test_worksheet_test_merge : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_merge() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 308, "test_merge" ) {} TestDescription_suite_test_worksheet_test_merge() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 323, "test_merge" ) {}
void runTest() { suite_test_worksheet.test_merge(); } void runTest() { suite_test_worksheet.test_merge(); }
} testDescription_suite_test_worksheet_test_merge; } testDescription_suite_test_worksheet_test_merge;
static class TestDescription_suite_test_worksheet_test_printer_settings : public CxxTest::RealTestDescription { static class TestDescription_suite_test_worksheet_test_printer_settings : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_printer_settings() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 320, "test_printer_settings" ) {} TestDescription_suite_test_worksheet_test_printer_settings() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 335, "test_printer_settings" ) {}
void runTest() { suite_test_worksheet.test_printer_settings(); } void runTest() { suite_test_worksheet.test_printer_settings(); }
} testDescription_suite_test_worksheet_test_printer_settings; } testDescription_suite_test_worksheet_test_printer_settings;
static class TestDescription_suite_test_worksheet_test_header_footer : public CxxTest::RealTestDescription { static class TestDescription_suite_test_worksheet_test_header_footer : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_header_footer() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 342, "test_header_footer" ) {} TestDescription_suite_test_worksheet_test_header_footer() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 357, "test_header_footer" ) {}
void runTest() { suite_test_worksheet.test_header_footer(); } void runTest() { suite_test_worksheet.test_header_footer(); }
} testDescription_suite_test_worksheet_test_header_footer; } testDescription_suite_test_worksheet_test_header_footer;
static class TestDescription_suite_test_worksheet_test_positioning_point : public CxxTest::RealTestDescription { static class TestDescription_suite_test_worksheet_test_positioning_point : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_positioning_point() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 419, "test_positioning_point" ) {} TestDescription_suite_test_worksheet_test_positioning_point() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 434, "test_positioning_point" ) {}
void runTest() { suite_test_worksheet.test_positioning_point(); } void runTest() { suite_test_worksheet.test_positioning_point(); }
} testDescription_suite_test_worksheet_test_positioning_point; } testDescription_suite_test_worksheet_test_positioning_point;
static class TestDescription_suite_test_worksheet_test_positioning_roundtrip : public CxxTest::RealTestDescription { static class TestDescription_suite_test_worksheet_test_positioning_roundtrip : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_positioning_roundtrip() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 427, "test_positioning_roundtrip" ) {} TestDescription_suite_test_worksheet_test_positioning_roundtrip() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 442, "test_positioning_roundtrip" ) {}
void runTest() { suite_test_worksheet.test_positioning_roundtrip(); } void runTest() { suite_test_worksheet.test_positioning_roundtrip(); }
} testDescription_suite_test_worksheet_test_positioning_roundtrip; } testDescription_suite_test_worksheet_test_positioning_roundtrip;
static class TestDescription_suite_test_worksheet_test_page_setup : public CxxTest::RealTestDescription { static class TestDescription_suite_test_worksheet_test_page_setup : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_page_setup() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 438, "test_page_setup" ) {} TestDescription_suite_test_worksheet_test_page_setup() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 453, "test_page_setup" ) {}
void runTest() { suite_test_worksheet.test_page_setup(); } void runTest() { suite_test_worksheet.test_page_setup(); }
} testDescription_suite_test_worksheet_test_page_setup; } testDescription_suite_test_worksheet_test_page_setup;
static class TestDescription_suite_test_worksheet_test_page_options : public CxxTest::RealTestDescription { static class TestDescription_suite_test_worksheet_test_page_options : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_worksheet_test_page_options() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 449, "test_page_options" ) {} TestDescription_suite_test_worksheet_test_page_options() : CxxTest::RealTestDescription( Tests_test_worksheet, suiteDescription_test_worksheet, 464, "test_page_options" ) {}
void runTest() { suite_test_worksheet.test_page_options(); } void runTest() { suite_test_worksheet.test_page_options(); }
} testDescription_suite_test_worksheet_test_page_options; } testDescription_suite_test_worksheet_test_page_options;
#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 test_write suite_test_write;
@ -1337,61 +1337,61 @@ public:
static class TestDescription_suite_test_write_test_write_height : public CxxTest::RealTestDescription { static class TestDescription_suite_test_write_test_write_height : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_write_test_write_height() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 103, "test_write_height" ) {} TestDescription_suite_test_write_test_write_height() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 105, "test_write_height" ) {}
void runTest() { suite_test_write.test_write_height(); } void runTest() { suite_test_write.test_write_height(); }
} testDescription_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 { static class TestDescription_suite_test_write_test_write_hyperlink : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_write_test_write_hyperlink() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 112, "test_write_hyperlink" ) {} TestDescription_suite_test_write_test_write_hyperlink() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 114, "test_write_hyperlink" ) {}
void runTest() { suite_test_write.test_write_hyperlink(); } void runTest() { suite_test_write.test_write_hyperlink(); }
} testDescription_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 { static class TestDescription_suite_test_write_test_write_hyperlink_rels : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_write_test_write_hyperlink_rels() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 121, "test_write_hyperlink_rels" ) {} TestDescription_suite_test_write_test_write_hyperlink_rels() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 123, "test_write_hyperlink_rels" ) {}
void runTest() { suite_test_write.test_write_hyperlink_rels(); } void runTest() { suite_test_write.test_write_hyperlink_rels(); }
} testDescription_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 { static class TestDescription_suite_test_write_test_hyperlink_value : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_write_test_hyperlink_value() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 135, "test_hyperlink_value" ) {} TestDescription_suite_test_write_test_hyperlink_value() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 137, "test_hyperlink_value" ) {}
void runTest() { suite_test_write.test_hyperlink_value(); } void runTest() { suite_test_write.test_hyperlink_value(); }
} testDescription_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 { static class TestDescription_suite_test_write_test_write_auto_filter : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_write_test_write_auto_filter() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 144, "test_write_auto_filter" ) {} TestDescription_suite_test_write_test_write_auto_filter() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 146, "test_write_auto_filter" ) {}
void runTest() { suite_test_write.test_write_auto_filter(); } void runTest() { suite_test_write.test_write_auto_filter(); }
} testDescription_suite_test_write_test_write_auto_filter; } testDescription_suite_test_write_test_write_auto_filter;
static class TestDescription_suite_test_write_test_freeze_panes_horiz : public CxxTest::RealTestDescription { static class TestDescription_suite_test_write_test_freeze_panes_horiz : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_write_test_freeze_panes_horiz() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 157, "test_freeze_panes_horiz" ) {} TestDescription_suite_test_write_test_freeze_panes_horiz() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 159, "test_freeze_panes_horiz" ) {}
void runTest() { suite_test_write.test_freeze_panes_horiz(); } void runTest() { suite_test_write.test_freeze_panes_horiz(); }
} testDescription_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 { static class TestDescription_suite_test_write_test_freeze_panes_vert : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_write_test_freeze_panes_vert() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 166, "test_freeze_panes_vert" ) {} TestDescription_suite_test_write_test_freeze_panes_vert() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 168, "test_freeze_panes_vert" ) {}
void runTest() { suite_test_write.test_freeze_panes_vert(); } void runTest() { suite_test_write.test_freeze_panes_vert(); }
} testDescription_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 { static class TestDescription_suite_test_write_test_freeze_panes_both : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_write_test_freeze_panes_both() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 175, "test_freeze_panes_both" ) {} TestDescription_suite_test_write_test_freeze_panes_both() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 177, "test_freeze_panes_both" ) {}
void runTest() { suite_test_write.test_freeze_panes_both(); } void runTest() { suite_test_write.test_freeze_panes_both(); }
} testDescription_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 { static class TestDescription_suite_test_write_test_long_number : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_write_test_long_number() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 184, "test_long_number" ) {} TestDescription_suite_test_write_test_long_number() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 186, "test_long_number" ) {}
void runTest() { suite_test_write.test_long_number(); } void runTest() { suite_test_write.test_long_number(); }
} testDescription_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 { static class TestDescription_suite_test_write_test_short_number : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_write_test_short_number() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 192, "test_short_number" ) {} TestDescription_suite_test_write_test_short_number() : CxxTest::RealTestDescription( Tests_test_write, suiteDescription_test_write, 194, "test_short_number" ) {}
void runTest() { suite_test_write.test_short_number(); } void runTest() { suite_test_write.test_short_number(); }
} testDescription_suite_test_write_test_short_number; } testDescription_suite_test_write_test_short_number;

View File

@ -100,7 +100,7 @@ public:
xlnt::worksheet ws = wb.create_sheet(); xlnt::worksheet ws = wb.create_sheet();
xlnt::cell cell(ws, "A1", "17.5"); xlnt::cell cell(ws, "A1", "17.5");
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type()); TS_ASSERT_EQUALS(xlnt::cell::type::string, cell.get_data_type());
} }
void test_1st() void test_1st()
@ -122,6 +122,8 @@ public:
void test_numeric() void test_numeric()
{ {
xlnt::workbook wb_guess_types;
wb.set_guess_types(true);
xlnt::worksheet ws = wb.create_sheet(); xlnt::worksheet ws = wb.create_sheet();
xlnt::cell cell(ws, "A1"); xlnt::cell cell(ws, "A1");
@ -183,10 +185,12 @@ public:
{ {
xlnt::worksheet ws = wb.create_sheet(); xlnt::worksheet ws = wb.create_sheet();
xlnt::cell cell(ws, "A1"); xlnt::cell cell(ws, "A1");
cell = "=42"; cell.set_formula("42");
TS_ASSERT_EQUALS(xlnt::cell::type::formula, cell.get_data_type()); TS_ASSERT(cell.has_formula());
cell = "=if(A1<4;-1;1)"; cell.clear_formula();
TS_ASSERT_EQUALS(xlnt::cell::type::formula, cell.get_data_type()); TS_ASSERT(!cell.has_formula());
cell.set_formula("if(A1<4;-1;1)");
TS_ASSERT(cell.has_formula());
} }
void test_boolean() void test_boolean()
@ -310,16 +314,12 @@ public:
xlnt::worksheet ws = wb.create_sheet(); xlnt::worksheet ws = wb.create_sheet();
xlnt::cell cell(ws, "A1"); xlnt::cell cell(ws, "A1");
TS_ASSERT_THROWS(cell.set_explicit_value("1", xlnt::cell::type::formula), TS_ASSERT_THROWS(cell.set_explicit_value("ABC", xlnt::cell::type::numeric), xlnt::data_type_exception);
xlnt::data_type_exception); TS_ASSERT_THROWS(cell.set_explicit_value(1, xlnt::cell::type::string), xlnt::data_type_exception);
TS_ASSERT_THROWS(cell.set_explicit_value(1, xlnt::cell::type::formula), TS_ASSERT_THROWS(cell.set_explicit_value(1.0, xlnt::cell::type::error), xlnt::data_type_exception);
xlnt::data_type_exception); TS_ASSERT_THROWS(cell.set_explicit_value("3", xlnt::cell::type::boolean), xlnt::data_type_exception);
TS_ASSERT_THROWS(cell.set_explicit_value(1.0, xlnt::cell::type::formula),
xlnt::data_type_exception);
TS_ASSERT_THROWS(cell.set_formula("1"), xlnt::data_type_exception);
TS_ASSERT_THROWS(cell.set_error("1"), xlnt::data_type_exception); TS_ASSERT_THROWS(cell.set_error("1"), xlnt::data_type_exception);
TS_ASSERT_THROWS(cell.set_hyperlink("1"), xlnt::data_type_exception); TS_ASSERT_THROWS(cell.set_hyperlink("1"), xlnt::data_type_exception);
TS_ASSERT_THROWS(cell.set_formula("#REF!"), xlnt::data_type_exception);
} }

View File

@ -186,17 +186,14 @@ public:
void test_repair_central_directory() void test_repair_central_directory()
{ {
TS_SKIP("repair not yet implemented"); std::string data_a = "foobarbaz" + xlnt::reader::CentralDirectorySignature;
/*
std::string data_a = "foobarbaz" + xlnt::CentralDirectorySignature;
std::string data_b = "bazbarfoo12345678901234567890"; std::string data_b = "bazbarfoo12345678901234567890";
auto f = xlnt::repair_central_directory(data_a + data_b, true); auto f = xlnt::reader::repair_central_directory(data_a + data_b);
TS_ASSERT_EQUALS(f, data_a + data_b.substr(0, 18)); TS_ASSERT_EQUALS(f, data_a + data_b.substr(0, 18));
f = xlnt::repair_central_directory(data_b, true); f = xlnt::reader::repair_central_directory(data_b);
TS_ASSERT_EQUALS(f, data_b); TS_ASSERT_EQUALS(f, data_b);
*/
} }
void test_read_no_theme() void test_read_no_theme()
@ -208,8 +205,6 @@ public:
void test_read_cell_formulae() void test_read_cell_formulae()
{ {
TS_SKIP("fast parse not yet implemented");
/*
xlnt::workbook wb; xlnt::workbook wb;
auto ws = wb.get_active_sheet(); auto ws = wb.get_active_sheet();
auto path = PathHelper::GetDataDirectory("/reader/worksheet_formula.xml"); auto path = PathHelper::GetDataDirectory("/reader/worksheet_formula.xml");
@ -217,33 +212,171 @@ public:
xlnt::reader::fast_parse(ws, ws_stream, {"", ""}, {}, 0); xlnt::reader::fast_parse(ws, ws_stream, {"", ""}, {}, 0);
auto b1 = ws.get_cell("B1"); auto b1 = ws.get_cell("B1");
TS_ASSERT_EQUALS(b1.get_data_type(), xlnt::cell::type::formula); TS_ASSERT(b1.has_formula());
TS_ASSERT_EQUALS(b1, "=CONCATENATE(A1, A2)"); TS_ASSERT_EQUALS(b1.get_formula(), "CONCATENATE(A1,A2)");
auto a6 = ws.get_cell("A6"); auto a6 = ws.get_cell("A6");
TS_ASSERT_EQUALS(a6.get_data_type(), xlnt::cell::type::formula); TS_ASSERT(a6.has_formula());
TS_ASSERT_EQUALS(a6, "=SUM(A4:A5)"); TS_ASSERT_EQUALS(a6.get_formula(), "SUM(A4:A5)");
*/
} }
void test_read_complex_formulae() void test_read_complex_formulae()
{ {
TS_SKIP("complex formulae not yet implemented"); TS_SKIP("not yet implemented");
/*
auto path = PathHelper::GetDataDirectory("/reader/formulae.xlsx");
auto wb = xlnt::reader::load_workbook(path);
auto ws = wb.get_active_sheet();
// Test normal forumlae
TS_ASSERT(!ws.get_cell("A1").has_formula());
TS_ASSERT(!ws.get_cell("A2").has_formula());
TS_ASSERT(ws.get_cell("A3").has_formula());
TS_ASSERT(ws.get_formula_attributes().find("A3") == ws.get_formula_attributes().end());
TS_ASSERT(ws.get_cell("A3").get_formula() == "12345");
TS_ASSERT(ws.get_cell("A4").has_formula());
TS_ASSERT(ws.get_formula_attributes().find("A3") == ws.get_formula_attributes().end());
ws.get_cell("A4").set_formula("A2+A3");
TS_ASSERT(ws.get_cell("A5").has_formula());
TS_ASSERT(ws.get_formula_attributes().find("A5") == ws.get_formula_attributes().end());
ws.get_cell("A5").set_formula("SUM(A2:A4)");
// Test unicode
std::string expected = "=IF(ISBLANK(B16), \"D\xFCsseldorf\", B16)";
TS_ASSERT(ws.get_cell("A16").get_formula() == expected);
// Test shared forumlae
TS_ASSERT(ws.get_cell("B7").get_data_type() == "f");
TS_ASSERT(ws.formula_attributes["B7"]["t"] == "shared");
TS_ASSERT(ws.formula_attributes["B7"]["si"] == "0");
TS_ASSERT(ws.formula_attributes["B7"]["ref"] == "B7:E7");
TS_ASSERT(ws.get_cell("B7").value == "=B4*2");
TS_ASSERT(ws.get_cell("C7").get_data_type() == "f");
TS_ASSERT(ws.formula_attributes["C7"]["t"] == "shared");
TS_ASSERT(ws.formula_attributes["C7"]["si"] == "0");
TS_ASSERT("ref" not in ws.formula_attributes["C7"]);
TS_ASSERT(ws.get_cell("C7").value == "=");
TS_ASSERT(ws.get_cell("D7").get_data_type() == "f");
TS_ASSERT(ws.formula_attributes["D7"]["t"] == "shared");
TS_ASSERT(ws.formula_attributes["D7"]["si"] == "0");
TS_ASSERT("ref" not in ws.formula_attributes["D7"]);
TS_ASSERT(ws.get_cell("D7").value == "=");
TS_ASSERT(ws.get_cell("E7").get_data_type() == "f");
TS_ASSERT(ws.formula_attributes["E7"]["t"] == "shared");
TS_ASSERT(ws.formula_attributes["E7"]["si"] == "0");
TS_ASSERT("ref" not in ws.formula_attributes["E7"]);
TS_ASSERT(ws.get_cell("E7").value == "=");
// Test array forumlae
TS_ASSERT(ws.get_cell("C10").get_data_type() == "f");
TS_ASSERT("ref" not in ws.formula_attributes["C10"]["ref"]);
TS_ASSERT(ws.formula_attributes["C10"]["t"] == "array");
TS_ASSERT("si" not in ws.formula_attributes["C10"]);
TS_ASSERT(ws.formula_attributes["C10"]["ref"] == "C10:C14");
TS_ASSERT(ws.get_cell("C10").value == "=SUM(A10:A14*B10:B14)");
TS_ASSERT(ws.get_cell("C11").get_data_type() != "f");
*/
} }
void test_data_only() void test_data_only()
{ {
TS_SKIP("data only not yet implemented"); auto path = PathHelper::GetDataDirectory("/reader/formulae.xlsx");
auto wb = xlnt::reader::load_workbook(path, false, true);
auto ws = wb.get_active_sheet();
TS_ASSERT(ws.get_formula_attributes().empty());
TS_ASSERT(ws.get_parent().get_data_only());
TS_ASSERT(ws.get_cell("A2").get_data_type() == xlnt::cell::type::numeric);
TS_ASSERT(ws.get_cell("A2") == 12345);
TS_ASSERT(!ws.get_cell("A2").has_formula());
TS_ASSERT(ws.get_cell("A3").get_data_type() == xlnt::cell::type::numeric);
TS_ASSERT(ws.get_cell("A3") == 12345);
TS_ASSERT(!ws.get_cell("A3").has_formula());
TS_ASSERT(ws.get_cell("A4").get_data_type() == xlnt::cell::type::numeric);
TS_ASSERT(ws.get_cell("A4") == 24690);
TS_ASSERT(!ws.get_cell("A4").has_formula());
TS_ASSERT(ws.get_cell("A5").get_data_type() == xlnt::cell::type::numeric);
TS_ASSERT(ws.get_cell("A5") == 49380);
TS_ASSERT(!ws.get_cell("A5").has_formula());
} }
void test_detect_worksheets() void test_detect_worksheets()
{ {
TS_SKIP("detect worksheets not yet implemented"); {
auto path = PathHelper::GetDataDirectory("/reader/bug137.xlsx");
xlnt::zip_file archive(path, xlnt::file_mode::open);
std::vector<std::pair<std::string, std::string>> expected =
{
{"xl/worksheets/sheet1.xml", "Sheet1"}
};
TS_ASSERT_EQUALS(xlnt::reader::detect_worksheets(archive), expected);
}
{
auto path = PathHelper::GetDataDirectory("/reader/contains_chartsheets.xlsx");
xlnt::zip_file archive(path, xlnt::file_mode::open);
std::vector<std::pair<std::string, std::string>> expected =
{
{"xl/worksheets/sheet1.xml", "data"},
{"xl/worksheets/sheet2.xml", "moredata"}
};
TS_ASSERT_EQUALS(xlnt::reader::detect_worksheets(archive), expected);
}
{
auto path = PathHelper::GetDataDirectory("/reader/bug304.xlsx");
xlnt::zip_file archive(path, xlnt::file_mode::open);
std::vector<std::pair<std::string, std::string>> expected =
{
{"xl/worksheets/sheet3.xml", "Sheet1"},
{"xl/worksheets/sheet2.xml", "Sheet2"},
{"xl/worksheets/sheet.xml", "Sheet3"}
};
TS_ASSERT_EQUALS(xlnt::reader::detect_worksheets(archive), expected);
}
} }
void test_read_rels() void test_read_rels()
{ {
TS_SKIP("not yet implemented"); {
std::vector<xlnt::relationship> expected =
{
{xlnt::relationship::type::theme, "rId3", "xl/theme/theme1.xml"},
{xlnt::relationship::type::worksheet, "rId2", "xl/worksheets/sheet1.xml"},
{xlnt::relationship::type::chartsheet, "rId1", "xl/chartsheets/sheet1.xml"},
{xlnt::relationship::type::shared_strings, "rId5", "xl/sharedStrings.xml"},
{xlnt::relationship::type::styles, "rId4", "xl/styles.xml"}
};
auto path = PathHelper::GetDataDirectory("/reader/bug137.xlsx");
xlnt::zip_file archive(path, xlnt::file_mode::open);
TS_ASSERT_EQUALS(xlnt::reader::read_relationships(archive, "xl/workbook.xml"), expected);
}
{
std::vector<xlnt::relationship> expected =
{
{xlnt::relationship::type::custom_xml, "rId8", "../customXml/item3.xml"},
{xlnt::relationship::type::worksheet, "rId3", "xl/worksheets/sheet.xml"},
{xlnt::relationship::type::custom_xml, "rId7", "../customXml/item2.xml"},
{xlnt::relationship::type::worksheet, "rId2", "xl/worksheets/sheet2.xml"},
{xlnt::relationship::type::worksheet, "rId1", "xl/worksheets/sheet3.xml"},
{xlnt::relationship::type::custom_xml, "rId6", "../customXml/item1.xml"},
{xlnt::relationship::type::styles, "rId5", "xl/styles.xml"},
{xlnt::relationship::type::theme, "rId4", "xl/theme/theme.xml"}
};
auto path = PathHelper::GetDataDirectory("/reader/bug304.xlsx");
xlnt::zip_file archive(path, xlnt::file_mode::open);
TS_ASSERT_EQUALS(xlnt::reader::read_relationships(archive, "xl/workbook.xml"), expected);
}
} }
void test_read_content_types() void test_read_content_types()
@ -305,7 +438,6 @@ public:
void test_guess_types() void test_guess_types()
{ {
TS_SKIP("type guessing not yet implemented");
bool guess; bool guess;
xlnt::cell::type dtype; xlnt::cell::type dtype;
std::vector<std::pair<bool, xlnt::cell::type>> test_cases = {{true, xlnt::cell::type::numeric}, {false, xlnt::cell::type::string}}; std::vector<std::pair<bool, xlnt::cell::type>> test_cases = {{true, xlnt::cell::type::numeric}, {false, xlnt::cell::type::string}};

View File

@ -132,22 +132,37 @@ public:
{ {
xlnt::worksheet ws(wb_); xlnt::worksheet ws(wb_);
ws.get_cell("A1") = ""; ws.get_cell("A1").set_null();
ws.get_cell("B2") = "0"; ws.get_cell("B2") = "0";
ws.get_cell("C4") = 0; ws.get_cell("C4") = 0;
ws.get_cell("D1").set_comment(xlnt::comment("Comment", "Comment"));
ws.garbage_collect(); ws.garbage_collect();
std::list<xlnt::cell> comparison_cells = {ws.get_cell("B2"), ws.get_cell("C4")}; auto cell_collection = ws.get_cell_collection();
std::set<xlnt::cell> cells(cell_collection.begin(), cell_collection.end());
std::set<xlnt::cell> expected = {ws.get_cell("B2"), ws.get_cell("C4"), ws.get_cell("D1")};
for(auto cell : ws.get_cell_collection()) // Set difference
std::set<xlnt::cell> difference;
for(auto a : expected)
{ {
auto match = std::find(comparison_cells.begin(), comparison_cells.end(), cell); if(cells.find(a) == cells.end())
TS_ASSERT_DIFFERS(match, comparison_cells.end()); {
comparison_cells.erase(match); difference.insert(a);
}
} }
TS_ASSERT(comparison_cells.empty()); for(auto a : cells)
{
if(expected.find(a) == expected.end())
{
difference.insert(a);
}
}
TS_ASSERT(difference.empty());
} }
void test_hyperlink_relationships() void test_hyperlink_relationships()

View File

@ -86,16 +86,18 @@ public:
auto ws = wb_.create_sheet(); auto ws = wb_.create_sheet();
ws.get_cell("F1") = 10; ws.get_cell("F1") = 10;
ws.get_cell("F2") = 32; ws.get_cell("F2") = 32;
ws.get_cell("F3") = "=F1+F2"; ws.get_cell("F3").set_formula("F1+F2");
auto content = xlnt::writer::write_worksheet(ws, {}, {}); 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() void test_write_style()
{ {
auto ws = wb_.create_sheet(); xlnt::workbook wb_guess_types;
wb_guess_types.set_guess_types(true);
auto ws = wb_guess_types.create_sheet();
ws.get_cell("F1") = "13%"; ws.get_cell("F1") = "13%";
auto style_id_by_hash = xlnt::style_writer(wb_).get_style_by_hash(); auto style_id_by_hash = xlnt::style_writer(wb_guess_types).get_style_by_hash();
auto content = xlnt::writer::write_worksheet(ws, {}, style_id_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));
} }