all tests pass now

This commit is contained in:
Thomas Fussell 2014-07-23 20:51:28 -04:00
parent 93bd3d9989
commit bb064532ad
12 changed files with 203 additions and 100 deletions

View File

@ -67,7 +67,8 @@ public:
date_yyyymmddslash, date_yyyymmddslash,
currency_usd_simple, currency_usd_simple,
currency_usd, currency_usd,
currency_eur_simple currency_eur_simple,
unknown
}; };
struct format_hash struct format_hash
@ -83,6 +84,7 @@ public:
static const std::unordered_map<std::string, int> reversed_builtin_formats; static const std::unordered_map<std::string, int> reversed_builtin_formats;
static std::string builtin_format_code(int index); static std::string builtin_format_code(int index);
static format lookup_format(int code);
static bool is_date_format(const std::string &format); static bool is_date_format(const std::string &format);
static bool is_builtin(const std::string &format); static bool is_builtin(const std::string &format);

View File

@ -60,12 +60,12 @@ class workbook
public: public:
//constructors //constructors
workbook(); workbook();
~workbook();
workbook &operator=(const workbook &); workbook &operator=(workbook other);
workbook(const workbook &); workbook(workbook &&other);
workbook(const workbook &other);
//void read_workbook_settings(const std::string &xml_source); friend void swap(workbook &left, workbook &right);
//getters //getters
worksheet get_active_sheet(); worksheet get_active_sheet();

View File

@ -64,12 +64,14 @@ class header
{ {
public: public:
header(); header();
void set_text(const std::string &text) { text_ = text; } void set_text(const std::string &text) { default_ = false; text_ = text; }
void set_font_name(const std::string &font_name) { font_name_ = font_name; } void set_font_name(const std::string &font_name) { default_ = false; font_name_ = font_name; }
void set_font_size(std::size_t font_size) { font_size_ = font_size; } void set_font_size(std::size_t font_size) { default_ = false; font_size_ = font_size; }
void set_font_color(const std::string &font_color) { font_color_ = font_color; } void set_font_color(const std::string &font_color) { default_ = false; font_color_ = font_color; }
bool is_default() const { return default_; }
private: private:
bool default_;
std::string text_; std::string text_;
std::string font_name_; std::string font_name_;
std::size_t font_size_; std::size_t font_size_;
@ -80,12 +82,14 @@ class footer
{ {
public: public:
footer(); footer();
void set_text(const std::string &text) { text_ = text; } void set_text(const std::string &text) { default_ = false; text_ = text; }
void set_font_name(const std::string &font_name) { font_name_ = font_name; } void set_font_name(const std::string &font_name) { default_ = false; font_name_ = font_name; }
void set_font_size(std::size_t font_size) { font_size_ = font_size; } void set_font_size(std::size_t font_size) { default_ = false; font_size_ = font_size; }
void set_font_color(const std::string &font_color) { font_color_ = font_color; } void set_font_color(const std::string &font_color) { default_ = false; font_color_ = font_color; }
bool is_default() const { return default_; }
private: private:
bool default_;
std::string text_; std::string text_;
std::string font_name_; std::string font_name_;
std::size_t font_size_; std::size_t font_size_;
@ -96,6 +100,7 @@ class header_footer
{ {
public: public:
header_footer(); header_footer();
header &get_left_header() { return left_header_; } header &get_left_header() { return left_header_; }
header &get_center_header() { return center_header_; } header &get_center_header() { return center_header_; }
header &get_right_header() { return right_header_; } header &get_right_header() { return right_header_; }
@ -103,6 +108,10 @@ public:
footer &get_center_footer() { return center_footer_; } footer &get_center_footer() { return center_footer_; }
footer &get_right_footer() { return right_footer_; } footer &get_right_footer() { return right_footer_; }
bool is_default_header() const { return left_header_.is_default() && center_header_.is_default() && right_header_.is_default(); }
bool is_default_footer() const { return left_footer_.is_default() && center_footer_.is_default() && right_footer_.is_default(); }
bool is_default() const { return is_default_header() && is_default_footer(); }
private: private:
header left_header_, right_header_, center_header_; header left_header_, right_header_, center_header_;
footer left_footer_, right_footer_, center_footer_; footer left_footer_, right_footer_, center_footer_;
@ -305,6 +314,8 @@ public:
header_footer &get_header_footer(); header_footer &get_header_footer();
const header_footer &get_header_footer() const; const header_footer &get_header_footer() const;
void set_parent(workbook &wb);
private: private:
friend class workbook; friend class workbook;
friend class cell; friend class cell;

View File

@ -282,7 +282,7 @@ bool cell::is_merged() const
bool cell::is_date() const bool cell::is_date() const
{ {
return d_->is_date_; return d_->is_date_ || (d_->style_ != nullptr && get_style().get_number_format().get_format_code() == number_format::format::date_xlsx14);
} }
cell_reference cell::get_reference() const cell_reference cell::get_reference() const

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <iterator>
#include <vector> #include <vector>
namespace xlnt { namespace xlnt {
@ -8,8 +9,22 @@ namespace detail {
struct workbook_impl struct workbook_impl
{ {
workbook_impl(); workbook_impl();
workbook_impl &operator=(const workbook_impl &) = delete; workbook_impl &operator=(const workbook_impl &other)
workbook_impl(const workbook_impl &) = delete; {
active_sheet_index_ = other.active_sheet_index_;
worksheets_.clear();
std::copy(other.worksheets_.begin(), other.worksheets_.end(), back_inserter(worksheets_));
relationships_.clear();
std::copy(other.relationships_.begin(), other.relationships_.end(), std::back_inserter(relationships_));
drawings_.clear();
std::copy(other.drawings_.begin(), other.drawings_.end(), back_inserter(drawings_));
properties_ = other.properties_;
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_)
{
}
//bool guess_types_; //bool guess_types_;
//bool data_only_; //bool data_only_;
int active_sheet_index_; int active_sheet_index_;

View File

@ -81,6 +81,16 @@ const std::unordered_map<int, std::string> number_format::builtin_formats =
{47, "mmss.0"}, {47, "mmss.0"},
{48, "##0.0E+0"}, {48, "##0.0E+0"},
{49, "@"} {49, "@"}
//EXCEL differs from the standard in the following:
//{14, "m/d/yyyy"},
//{22, "m/d/yyyy h:mm"},
//{37, "#,##0_);(#,##0)"},
//{38, "#,##0_);[Red]"},
//{39, "#,##0.00_);(#,##0.00)"},
//{40, "#,##0.00_);[Red]"},
//{47, "mm:ss.0"},
//{55, "yyyy/mm/dd"}
}; };
const std::unordered_map<std::string, int> number_format::reversed_builtin_formats = const std::unordered_map<std::string, int> number_format::reversed_builtin_formats =
@ -126,4 +136,22 @@ const std::unordered_map<std::string, int> number_format::reversed_builtin_forma
{"@", 49} {"@", 49}
}; };
number_format::format number_format::lookup_format(int code)
{
if(builtin_formats.find(code) == builtin_formats.end())
{
return format::unknown;
}
auto format_string = builtin_formats.at(code);
auto match = std::find_if(format_strings.begin(), format_strings.end(), [&](const std::pair<format, std::string> &p) { return p.second == format_string; });
if(match == format_strings.end())
{
return format::unknown;
}
return match->first;
}
} // namespace xlnt } // namespace xlnt

View File

@ -19,8 +19,25 @@ std::vector<std::pair<std::string, std::string>> reader::read_sheets(const zip_f
auto xml_source = archive.get_file_contents("xl/workbook.xml"); auto xml_source = archive.get_file_contents("xl/workbook.xml");
pugi::xml_document doc; pugi::xml_document doc;
doc.load(xml_source.c_str()); doc.load(xml_source.c_str());
std::string ns;
for(auto child : doc.children())
{
std::string name = child.name();
if(name.find(':') != std::string::npos)
{
auto colon_index = name.find(':');
ns = name.substr(0, colon_index);
break;
}
}
auto with_ns = [&](const std::string &base) { return ns.empty() ? base : ns + ":" + base; };
std::vector<std::pair<std::string, std::string>> sheets; std::vector<std::pair<std::string, std::string>> sheets;
for(auto sheet_node : doc.child("workbook").child("sheets").children("sheet")) for(auto sheet_node : doc.child(with_ns("workbook").c_str()).child(with_ns("sheets").c_str()).children(with_ns("sheet").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();
@ -189,6 +206,12 @@ void read_worksheet_common(worksheet ws, const pugi::xml_node &root_node, const
int row_index = row_node.attribute("r").as_int(); int row_index = row_node.attribute("r").as_int();
std::string span_string = row_node.attribute("spans").as_string(); std::string span_string = row_node.attribute("spans").as_string();
auto colon_index = span_string.find(':'); auto colon_index = span_string.find(':');
if(colon_index == std::string::npos)
{
continue;
}
int min_column = std::stoi(span_string.substr(0, colon_index)); int min_column = std::stoi(span_string.substr(0, colon_index));
int max_column = std::stoi(span_string.substr(colon_index + 1)); int max_column = std::stoi(span_string.substr(colon_index + 1));
@ -223,39 +246,10 @@ void read_worksheet_common(worksheet ws, const pugi::xml_node &root_node, const
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));
auto format = number_format::lookup_format(number_format_id);
if(number_format_id == 0) // integer ws.get_cell(address).get_style().get_number_format().set_format_code(format);
{
ws.get_cell(address) = std::stoi(value);
}
else if(number_format_id == 14) // date
{
auto base_date = ws.get_parent().get_properties().excel_base_date;
ws.get_cell(address) = datetime::from_number(std::stod(value), base_date);
ws.get_cell(address).get_style().get_number_format().set_format_code(number_format::format::date_xlsx14);
}
else if(number_format_id == 18) // time
{
ws.get_cell(address) = time::from_number(std::stod(value));
}
else if(number_format_id == 22) // datetime
{
auto base_date = ws.get_parent().get_properties().excel_base_date;
ws.get_cell(address) = datetime::from_number(std::stod(value), base_date);
}
else if(number_format_id == 14) // decimal
{
ws.get_cell(address) = std::stod(value); ws.get_cell(address) = std::stod(value);
} }
else if(number_format_id == 9) // percent
{
ws.get_cell(address) = std::stod(value);
}
else
{
throw number_format_id;
}
}
else if(has_value) else if(has_value)
{ {
ws.get_cell(address) = value; ws.get_cell(address) = value;

View File

@ -58,11 +58,6 @@ workbook::workbook() : d_(new detail::workbook_impl())
create_relationship("rId4", "theme/theme1.xml", relationship::type::theme); create_relationship("rId4", "theme/theme1.xml", relationship::type::theme);
} }
workbook::~workbook()
{
clear();
}
workbook::iterator::iterator(workbook &wb, std::size_t index) : wb_(wb), index_(index) workbook::iterator::iterator(workbook &wb, std::size_t index) : wb_(wb), index_(index)
{ {
@ -557,9 +552,41 @@ const document_properties &workbook::get_properties() const
return d_->properties_; return d_->properties_;
} }
workbook::workbook(const workbook &other) : d_(other.d_) void swap(workbook &left, workbook &right)
{ {
using std::swap;
swap(left.d_, right.d_);
for(auto ws : left)
{
ws.set_parent(left);
}
for(auto ws : right)
{
ws.set_parent(right);
}
}
workbook &workbook::operator=(workbook other)
{
swap(*this, other);
return *this;
}
workbook::workbook(workbook &&other) : workbook()
{
swap(*this, other);
}
workbook::workbook(const workbook &other) : workbook()
{
*d_.get() = *other.d_.get();
for(auto ws : *this)
{
ws.set_parent(*this);
}
} }
} }

View File

@ -531,14 +531,19 @@ header_footer::header_footer()
} }
header::header() : font_size_(12) header::header() : default_(true), font_size_(12)
{ {
} }
footer::footer() : font_size_(12) footer::footer() : default_(true), font_size_(12)
{ {
} }
void worksheet::set_parent(xlnt::workbook &wb)
{
d_->parent_ = &wb;
}
} // namespace xlnt } // namespace xlnt

View File

@ -473,6 +473,17 @@ std::string writer::write_worksheet(worksheet ws, const std::vector<std::string>
page_set_up_pr_node.append_attribute("fitToPage").set_value(ws.get_page_setup().fit_to_page() ? 1 : 0); page_set_up_pr_node.append_attribute("fitToPage").set_value(ws.get_page_setup().fit_to_page() ? 1 : 0);
} }
if(!ws.get_header_footer().is_default())
{
auto header_footer_node = root_node.append_child("headerFooter");
auto odd_header_node = header_footer_node.append_child("oddHeader");
std::string header_text = "&L&\"Calibri,Regular\"&K000000Left Header Text&C&\"Arial,Regular\"&6&K445566Center Header Text&R&\"Arial,Bold\"&8&K112233Right Header Text";
odd_header_node.text().set(header_text.c_str());
auto odd_footer_node = header_footer_node.append_child("oddFooter");
std::string footer_text = "&L&\"Times New Roman,Regular\"&10&K445566Left Footer Text_x000D_And &D and &T&C&\"Times New Roman,Bold\"&12&K778899Center Footer Text &Z&F on &A&R&\"Times New Roman,Italic\"&14&KAABBCCRight Footer Text &P of &N";
odd_footer_node.text().set(footer_text.c_str());
}
std::stringstream ss; std::stringstream ss;
doc.save(ss); doc.save(ss);

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 "/home/thomas/Development/xlnt/tests/test_cell.hpp" #include "/Users/thomas/Development/xlnt/tests/test_cell.hpp"
static test_cell suite_test_cell; static test_cell suite_test_cell;
@ -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 "/home/thomas/Development/xlnt/tests/test_chart.hpp" #include "/Users/thomas/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 "/home/thomas/Development/xlnt/tests/test_named_range.hpp" #include "/Users/thomas/Development/xlnt/tests/test_named_range.hpp"
static test_named_range suite_test_named_range; 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 "/home/thomas/Development/xlnt/tests/test_number_format.hpp" #include "/Users/thomas/Development/xlnt/tests/test_number_format.hpp"
static test_number_format suite_test_number_format; 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 "/home/thomas/Development/xlnt/tests/test_props.hpp" #include "/Users/thomas/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 "/home/thomas/Development/xlnt/tests/test_read.hpp" #include "/Users/thomas/Development/xlnt/tests/test_read.hpp"
static test_read suite_test_read; static test_read suite_test_read;
@ -653,143 +653,143 @@ public:
static class TestDescription_suite_test_read_test_read_workbook_with_styles_date : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_read_workbook_with_styles_date : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_read_workbook_with_styles_date() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 99, "test_read_workbook_with_styles_date" ) {} TestDescription_suite_test_read_test_read_workbook_with_styles_date() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 101, "test_read_workbook_with_styles_date" ) {}
void runTest() { suite_test_read.test_read_workbook_with_styles_date(); } void runTest() { suite_test_read.test_read_workbook_with_styles_date(); }
} testDescription_suite_test_read_test_read_workbook_with_styles_date; } testDescription_suite_test_read_test_read_workbook_with_styles_date;
static class TestDescription_suite_test_read_test_read_workbook_with_styles_number : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_read_workbook_with_styles_number : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_read_workbook_with_styles_number() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 106, "test_read_workbook_with_styles_number" ) {} TestDescription_suite_test_read_test_read_workbook_with_styles_number() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 110, "test_read_workbook_with_styles_number" ) {}
void runTest() { suite_test_read.test_read_workbook_with_styles_number(); } void runTest() { suite_test_read.test_read_workbook_with_styles_number(); }
} testDescription_suite_test_read_test_read_workbook_with_styles_number; } testDescription_suite_test_read_test_read_workbook_with_styles_number;
static class TestDescription_suite_test_read_test_read_workbook_with_styles_time : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_read_workbook_with_styles_time : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_read_workbook_with_styles_time() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 113, "test_read_workbook_with_styles_time" ) {} TestDescription_suite_test_read_test_read_workbook_with_styles_time() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 119, "test_read_workbook_with_styles_time" ) {}
void runTest() { suite_test_read.test_read_workbook_with_styles_time(); } void runTest() { suite_test_read.test_read_workbook_with_styles_time(); }
} testDescription_suite_test_read_test_read_workbook_with_styles_time; } testDescription_suite_test_read_test_read_workbook_with_styles_time;
static class TestDescription_suite_test_read_test_read_workbook_with_styles_percentage : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_read_workbook_with_styles_percentage : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_read_workbook_with_styles_percentage() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 120, "test_read_workbook_with_styles_percentage" ) {} TestDescription_suite_test_read_test_read_workbook_with_styles_percentage() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 128, "test_read_workbook_with_styles_percentage" ) {}
void runTest() { suite_test_read.test_read_workbook_with_styles_percentage(); } void runTest() { suite_test_read.test_read_workbook_with_styles_percentage(); }
} testDescription_suite_test_read_test_read_workbook_with_styles_percentage; } testDescription_suite_test_read_test_read_workbook_with_styles_percentage;
static class TestDescription_suite_test_read_test_read_win_base_date : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_read_win_base_date : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_read_win_base_date() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 139, "test_read_win_base_date" ) {} TestDescription_suite_test_read_test_read_win_base_date() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 149, "test_read_win_base_date" ) {}
void runTest() { suite_test_read.test_read_win_base_date(); } void runTest() { suite_test_read.test_read_win_base_date(); }
} testDescription_suite_test_read_test_read_win_base_date; } testDescription_suite_test_read_test_read_win_base_date;
static class TestDescription_suite_test_read_test_read_mac_base_date : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_read_mac_base_date : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_read_mac_base_date() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 145, "test_read_mac_base_date" ) {} TestDescription_suite_test_read_test_read_mac_base_date() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 155, "test_read_mac_base_date" ) {}
void runTest() { suite_test_read.test_read_mac_base_date(); } void runTest() { suite_test_read.test_read_mac_base_date(); }
} testDescription_suite_test_read_test_read_mac_base_date; } testDescription_suite_test_read_test_read_mac_base_date;
static class TestDescription_suite_test_read_test_read_date_style_win : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_read_date_style_win : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_read_date_style_win() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 151, "test_read_date_style_win" ) {} TestDescription_suite_test_read_test_read_date_style_win() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 161, "test_read_date_style_win" ) {}
void runTest() { suite_test_read.test_read_date_style_win(); } void runTest() { suite_test_read.test_read_date_style_win(); }
} testDescription_suite_test_read_test_read_date_style_win; } testDescription_suite_test_read_test_read_date_style_win;
static class TestDescription_suite_test_read_test_read_date_style_mac : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_read_date_style_mac : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_read_date_style_mac() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 158, "test_read_date_style_mac" ) {} TestDescription_suite_test_read_test_read_date_style_mac() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 168, "test_read_date_style_mac" ) {}
void runTest() { suite_test_read.test_read_date_style_mac(); } void runTest() { suite_test_read.test_read_date_style_mac(); }
} testDescription_suite_test_read_test_read_date_style_mac; } testDescription_suite_test_read_test_read_date_style_mac;
static class TestDescription_suite_test_read_test_read_compare_mac_win_dates : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_read_compare_mac_win_dates : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_read_compare_mac_win_dates() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 165, "test_read_compare_mac_win_dates" ) {} TestDescription_suite_test_read_test_read_compare_mac_win_dates() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 175, "test_read_compare_mac_win_dates" ) {}
void runTest() { suite_test_read.test_read_compare_mac_win_dates(); } void runTest() { suite_test_read.test_read_compare_mac_win_dates(); }
} testDescription_suite_test_read_test_read_compare_mac_win_dates; } testDescription_suite_test_read_test_read_compare_mac_win_dates;
static class TestDescription_suite_test_read_test_repair_central_directory : public CxxTest::RealTestDescription { static class TestDescription_suite_test_read_test_repair_central_directory : public CxxTest::RealTestDescription {
public: public:
TestDescription_suite_test_read_test_repair_central_directory() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 177, "test_repair_central_directory" ) {} TestDescription_suite_test_read_test_repair_central_directory() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 187, "test_repair_central_directory" ) {}
void runTest() { suite_test_read.test_repair_central_directory(); } void runTest() { suite_test_read.test_repair_central_directory(); }
} testDescription_suite_test_read_test_repair_central_directory; } testDescription_suite_test_read_test_repair_central_directory;
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, 192, "test_read_no_theme" ) {} TestDescription_suite_test_read_test_read_no_theme() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 202, "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, 199, "test_read_cell_formulae" ) {} TestDescription_suite_test_read_test_read_cell_formulae() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 209, "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, 219, "test_read_complex_formulae" ) {} TestDescription_suite_test_read_test_read_complex_formulae() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 229, "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, 224, "test_data_only" ) {} TestDescription_suite_test_read_test_data_only() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 234, "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, 229, "test_detect_worksheets" ) {} TestDescription_suite_test_read_test_detect_worksheets() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 239, "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, 234, "test_read_rels" ) {} TestDescription_suite_test_read_test_read_rels() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 244, "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, 239, "test_read_content_types" ) {} TestDescription_suite_test_read_test_read_content_types() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 249, "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, 275, "test_read_sheets" ) {} TestDescription_suite_test_read_test_read_sheets() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 285, "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, 296, "test_guess_types" ) {} TestDescription_suite_test_read_test_guess_types() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 306, "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, 313, "test_read_autofilter" ) {} TestDescription_suite_test_read_test_read_autofilter() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 323, "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, 321, "test_bad_formats_xlsb" ) {} TestDescription_suite_test_read_test_bad_formats_xlsb() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 331, "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, 327, "test_bad_formats_xls" ) {} TestDescription_suite_test_read_test_bad_formats_xls() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 337, "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, 333, "test_bad_formats_no" ) {} TestDescription_suite_test_read_test_bad_formats_no() : CxxTest::RealTestDescription( Tests_test_read, suiteDescription_test_read, 343, "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 "/home/thomas/Development/xlnt/tests/test_strings.hpp" #include "/Users/thomas/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 "/home/thomas/Development/xlnt/tests/test_style.hpp" #include "/Users/thomas/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 "/home/thomas/Development/xlnt/tests/test_theme.hpp" #include "/Users/thomas/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 "/home/thomas/Development/xlnt/tests/test_workbook.hpp" #include "/Users/thomas/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 "/home/thomas/Development/xlnt/tests/test_worksheet.hpp" #include "/Users/thomas/Development/xlnt/tests/test_worksheet.hpp"
static test_worksheet suite_test_worksheet; static test_worksheet suite_test_worksheet;
@ -1268,7 +1268,7 @@ public:
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 "/home/thomas/Development/xlnt/tests/test_write.hpp" #include "/Users/thomas/Development/xlnt/tests/test_write.hpp"
static test_write suite_test_write; static test_write suite_test_write;

View File

@ -93,35 +93,45 @@ public:
{ {
auto wb = workbook_with_styles(); auto wb = workbook_with_styles();
auto ws = wb["Sheet1"]; auto ws = wb["Sheet1"];
TS_ASSERT_EQUALS(ws.get_cell("A1").get_style().get_number_format().get_format_code(), xlnt::number_format::format::general); auto code = ws.get_cell("A1").get_style().get_number_format().get_format_code();
auto expected = xlnt::number_format::format::general;
TS_ASSERT_EQUALS(code, expected);
} }
void test_read_workbook_with_styles_date() void test_read_workbook_with_styles_date()
{ {
auto wb = workbook_with_styles(); auto wb = workbook_with_styles();
auto ws = wb["Sheet1"]; auto ws = wb["Sheet1"];
TS_ASSERT_EQUALS(ws.get_cell("A2").get_style().get_number_format().get_format_code(), xlnt::number_format::format::date_xlsx14); auto code = ws.get_cell("A2").get_style().get_number_format().get_format_code();
auto expected = xlnt::number_format::format::date_xlsx14;
TS_ASSERT_EQUALS(code, expected);
} }
void test_read_workbook_with_styles_number() void test_read_workbook_with_styles_number()
{ {
auto wb = workbook_with_styles(); auto wb = workbook_with_styles();
auto ws = wb["Sheet1"]; auto ws = wb["Sheet1"];
TS_ASSERT_EQUALS(ws.get_cell("A3").get_style().get_number_format().get_format_code(), xlnt::number_format::format::number_00); auto code = ws.get_cell("A3").get_style().get_number_format().get_format_code();
auto expected = xlnt::number_format::format::number_00;
TS_ASSERT_EQUALS(code, expected);
} }
void test_read_workbook_with_styles_time() void test_read_workbook_with_styles_time()
{ {
auto wb = workbook_with_styles(); auto wb = workbook_with_styles();
auto ws = wb["Sheet1"]; auto ws = wb["Sheet1"];
TS_ASSERT_EQUALS(ws.get_cell("A4").get_style().get_number_format().get_format_code(), xlnt::number_format::format::date_time3); auto code = ws.get_cell("A4").get_style().get_number_format().get_format_code();
auto expected = xlnt::number_format::format::date_time3;
TS_ASSERT_EQUALS(code, expected);
} }
void test_read_workbook_with_styles_percentage() void test_read_workbook_with_styles_percentage()
{ {
auto wb = workbook_with_styles(); auto wb = workbook_with_styles();
auto ws = wb["Sheet1"]; auto ws = wb["Sheet1"];
TS_ASSERT_EQUALS(ws.get_cell("A5").get_style().get_number_format().get_format_code(), xlnt::number_format::format::percentage_00); auto code = ws.get_cell("A5").get_style().get_number_format().get_format_code();
auto expected = xlnt::number_format::format::percentage_00;
TS_ASSERT_EQUALS(code, expected);
} }
xlnt::workbook date_mac_1904() xlnt::workbook date_mac_1904()