mirror of
https://github.com/tfussell/xlnt.git
synced 2024-03-22 13:11:17 +08:00
change a few things
This commit is contained in:
parent
e92f1a624e
commit
7edef82577
|
@ -66,6 +66,9 @@ project "xlnt"
|
|||
}
|
||||
files {
|
||||
"../source/*.cpp",
|
||||
"../source/*.h",
|
||||
"../source/detail/*.cpp",
|
||||
"../source/detail/*.h",
|
||||
"../include/xlnt/*.h"
|
||||
}
|
||||
flags {
|
||||
|
|
|
@ -9,9 +9,14 @@
|
|||
namespace xlnt {
|
||||
|
||||
class cell_reference;
|
||||
class date;
|
||||
class datetime;
|
||||
class time;
|
||||
class worksheet;
|
||||
|
||||
|
||||
namespace detail {
|
||||
struct cell_impl;
|
||||
} // namespace detail
|
||||
|
||||
typedef std::string comment;
|
||||
|
||||
|
@ -291,19 +296,17 @@ private:
|
|||
/// </remarks>
|
||||
class cell
|
||||
{
|
||||
public:
|
||||
public:
|
||||
enum class type
|
||||
{
|
||||
null,
|
||||
numeric,
|
||||
string,
|
||||
date,
|
||||
formula,
|
||||
boolean,
|
||||
error,
|
||||
hyperlink
|
||||
numeric,
|
||||
string,
|
||||
formula,
|
||||
boolean,
|
||||
error
|
||||
};
|
||||
|
||||
|
||||
static const std::unordered_map<std::string, int> ErrorCodes;
|
||||
|
||||
static std::string check_string(const std::string &value);
|
||||
|
@ -321,24 +324,19 @@ public:
|
|||
std::string to_string() const;
|
||||
|
||||
void set_explicit_value(const std::string &value, type data_type);
|
||||
void set_explicit_value(int value, type data_type);
|
||||
void set_explicit_value(double value, type data_type);
|
||||
void set_explicit_value(const date &value, type data_type);
|
||||
void set_explicit_value(const time &value, type data_type);
|
||||
void set_explicit_value(const datetime &value, type data_type);
|
||||
type data_type_for_value(const std::string &value);
|
||||
|
||||
bool bind_value();
|
||||
bool bind_value(int value);
|
||||
bool bind_value(double value);
|
||||
bool bind_value(const std::string &value);
|
||||
bool bind_value(const char *value);
|
||||
bool bind_value(bool value);
|
||||
bool bind_value(const tm &value);
|
||||
|
||||
bool is_merged() const;
|
||||
void set_merged(bool merged);
|
||||
|
||||
std::string get_hyperlink() const;
|
||||
void set_hyperlink(const std::string &value);
|
||||
|
||||
std::string get_hyperlink_rel_id() const;
|
||||
|
||||
void set_number_format(const std::string &format_code);
|
||||
|
||||
bool has_style() const;
|
||||
|
@ -356,6 +354,14 @@ public:
|
|||
|
||||
comment get_comment() const;
|
||||
void set_comment(comment comment);
|
||||
|
||||
std::string get_formula() const;
|
||||
void set_formula(const std::string &formula);
|
||||
|
||||
std::string get_error() const;
|
||||
void set_error(const std::string &error);
|
||||
|
||||
void set_null();
|
||||
|
||||
cell &operator=(const cell &rhs);
|
||||
cell &operator=(bool value);
|
||||
|
@ -363,29 +369,35 @@ public:
|
|||
cell &operator=(double value);
|
||||
cell &operator=(const std::string &value);
|
||||
cell &operator=(const char *value);
|
||||
cell &operator=(const tm &value);
|
||||
cell &operator=(const date &value);
|
||||
cell &operator=(const time &value);
|
||||
cell &operator=(const datetime &value);
|
||||
|
||||
bool operator==(const cell &comparand) const { return d_ == comparand.d_; }
|
||||
bool operator==(std::nullptr_t) const;
|
||||
bool operator==(bool comparand) const;
|
||||
bool operator==(int comparand) const;
|
||||
bool operator==(double comparand) const;
|
||||
bool operator==(const std::string &comparand) const;
|
||||
bool operator==(const char *comparand) const;
|
||||
bool operator==(const tm &comparand) const;
|
||||
bool operator==(const cell &comparand) const { return d_ == comparand.d_; }
|
||||
|
||||
bool operator==(const date &comparand) const;
|
||||
bool operator==(const time &comparand) const;
|
||||
bool operator==(const datetime &comparand) const;
|
||||
|
||||
friend bool operator==(std::nullptr_t, const cell &cell);
|
||||
friend bool operator==(bool comparand, const cell &cell);
|
||||
friend bool operator==(int comparand, const cell &cell);
|
||||
friend bool operator==(double comparand, const cell &cell);
|
||||
friend bool operator==(const std::string &comparand, const cell &cell);
|
||||
friend bool operator==(const char *comparand, const cell &cell);
|
||||
friend bool operator==(const tm &comparand, const cell &cell);
|
||||
friend bool operator==(const date &comparand, const cell &cell);
|
||||
friend bool operator==(const time &comparand, const cell &cell);
|
||||
friend bool operator==(const datetime &comparand, const cell &cell);
|
||||
|
||||
private:
|
||||
friend class worksheet;
|
||||
cell(cell_impl *d);
|
||||
cell_impl *d_;
|
||||
cell(detail::cell_impl *d);
|
||||
detail::cell_impl *d_;
|
||||
};
|
||||
|
||||
inline std::ostream &operator<<(std::ostream &stream, const xlnt::cell &cell)
|
||||
|
@ -394,4 +406,3 @@ inline std::ostream &operator<<(std::ostream &stream, const xlnt::cell &cell)
|
|||
}
|
||||
|
||||
} // namespace xlnt
|
||||
|
||||
|
|
|
@ -11,12 +11,30 @@ public:
|
|||
bad_sheet_title(const std::string &title);
|
||||
};
|
||||
|
||||
class bad_cell_coordinates : public std::runtime_error
|
||||
class cell_coordinates_exception : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
bad_cell_coordinates(int row, int column);
|
||||
cell_coordinates_exception(int row, int column);
|
||||
|
||||
bad_cell_coordinates(const std::string &coord_string);
|
||||
cell_coordinates_exception(const std::string &coord_string);
|
||||
};
|
||||
|
||||
class workbook_already_saved : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
workbook_already_saved();
|
||||
};
|
||||
|
||||
class data_type_exception : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
data_type_exception();
|
||||
};
|
||||
|
||||
class column_string_index_exception : public std::runtime_error
|
||||
{
|
||||
public:
|
||||
column_string_index_exception();
|
||||
};
|
||||
|
||||
} // namespace xlnt
|
||||
|
|
50
include/xlnt/datetime.h
Normal file
50
include/xlnt/datetime.h
Normal file
|
@ -0,0 +1,50 @@
|
|||
#pragma once
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
struct date
|
||||
{
|
||||
date(int year, int month, int day)
|
||||
: year(year), month(month), day(day)
|
||||
{
|
||||
}
|
||||
|
||||
int year;
|
||||
int month;
|
||||
int day;
|
||||
};
|
||||
|
||||
struct time
|
||||
{
|
||||
time(int hour = 0, int minute = 0, int second = 0, int microsecond = 0)
|
||||
: hour(hour), minute(minute), second(second), microsecond(microsecond)
|
||||
{
|
||||
}
|
||||
|
||||
explicit time(long double number);
|
||||
|
||||
int hour;
|
||||
int minute;
|
||||
int second;
|
||||
int microsecond;
|
||||
};
|
||||
|
||||
struct datetime
|
||||
{
|
||||
static datetime now();
|
||||
|
||||
datetime(int year, int month, int day, int hour = 0, int minute = 0, int second = 0, int microsecond = 0)
|
||||
: year(year), month(month), day(day), hour(hour), minute(minute), second(second), microsecond(microsecond)
|
||||
{
|
||||
}
|
||||
|
||||
int year;
|
||||
int month;
|
||||
int day;
|
||||
int hour;
|
||||
int minute;
|
||||
int second;
|
||||
int microsecond;
|
||||
};
|
||||
|
||||
} // namespace xlnt
|
|
@ -12,8 +12,10 @@ class range;
|
|||
class range_reference;
|
||||
class relationship;
|
||||
class worksheet;
|
||||
|
||||
|
||||
namespace detail {
|
||||
struct workbook_impl;
|
||||
} // namespace detail
|
||||
|
||||
enum class optimization
|
||||
{
|
||||
|
@ -123,7 +125,7 @@ public:
|
|||
|
||||
private:
|
||||
friend class worksheet;
|
||||
workbook_impl *d_;
|
||||
detail::workbook_impl *d_;
|
||||
};
|
||||
|
||||
} // namespace xlnt
|
||||
|
|
|
@ -12,12 +12,15 @@ namespace xlnt {
|
|||
|
||||
class cell;
|
||||
class cell_reference;
|
||||
class date;
|
||||
class range;
|
||||
class range_reference;
|
||||
class relationship;
|
||||
class workbook;
|
||||
|
||||
|
||||
namespace detail {
|
||||
struct worksheet_impl;
|
||||
} // namespace detail
|
||||
|
||||
struct page_setup
|
||||
{
|
||||
|
@ -173,6 +176,8 @@ public:
|
|||
|
||||
// append
|
||||
void append(const std::vector<std::string> &cells);
|
||||
void append(const std::vector<int> &cells);
|
||||
void append(const std::vector<date> &cells);
|
||||
void append(const std::unordered_map<std::string, std::string> &cells);
|
||||
void append(const std::unordered_map<int, std::string> &cells);
|
||||
|
||||
|
@ -205,8 +210,8 @@ public:
|
|||
private:
|
||||
friend class workbook;
|
||||
friend class cell;
|
||||
worksheet(worksheet_impl *d);
|
||||
worksheet_impl *d_;
|
||||
worksheet(detail::worksheet_impl *d);
|
||||
detail::worksheet_impl *d_;
|
||||
};
|
||||
|
||||
} // namespace xlnt
|
||||
|
|
|
@ -9,6 +9,7 @@
|
|||
#include "cell.h"
|
||||
#include "cell_reference.h"
|
||||
#include "custom_exceptions.h"
|
||||
#include "datetime.h"
|
||||
#include "drawing.h"
|
||||
#include "range.h"
|
||||
#include "reader.h"
|
||||
|
|
245
source/cell.cpp
245
source/cell.cpp
|
@ -3,22 +3,13 @@
|
|||
#include <sstream>
|
||||
|
||||
#include "cell.h"
|
||||
#include "cell_impl.h"
|
||||
#include "cell_reference.h"
|
||||
#include "datetime.h"
|
||||
#include "relationship.h"
|
||||
#include "worksheet.h"
|
||||
#include "detail/cell_impl.h"
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
cell_impl::cell_impl() : hyperlink_rel("hyperlink"), column(0), row(0), type_(type::null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
cell_impl::cell_impl(int column_index, int row_index) : hyperlink_rel("hyperlink"), column(column_index), row(row_index), type_(type::null)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
const xlnt::color xlnt::color::black(0);
|
||||
const xlnt::color xlnt::color::white(1);
|
||||
|
@ -38,9 +29,8 @@ cell::cell() : d_(nullptr)
|
|||
{
|
||||
}
|
||||
|
||||
cell::cell(cell_impl *d) : d_(d)
|
||||
cell::cell(detail::cell_impl *d) : d_(d)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
cell::cell(worksheet worksheet, const cell_reference &reference, const std::string &initial_value) : d_(nullptr)
|
||||
|
@ -58,22 +48,20 @@ std::string cell::get_value() const
|
|||
{
|
||||
switch(d_->type_)
|
||||
{
|
||||
case cell_impl::type::string:
|
||||
return d_->string_value;
|
||||
case cell_impl::type::numeric:
|
||||
return std::to_string(d_->numeric_value);
|
||||
case cell_impl::type::formula:
|
||||
return d_->formula_value;
|
||||
case cell_impl::type::error:
|
||||
return d_->error_value;
|
||||
case cell_impl::type::null:
|
||||
return "";
|
||||
case cell_impl::type::date:
|
||||
return "00:00:00";
|
||||
case cell_impl::type::boolean:
|
||||
return d_->numeric_value != 0 ? "TRUE" : "FALSE";
|
||||
default:
|
||||
throw std::runtime_error("bad enum");
|
||||
case type::string:
|
||||
return d_->string_value;
|
||||
case type::numeric:
|
||||
return std::to_string(d_->numeric_value);
|
||||
case type::formula:
|
||||
return d_->string_value;
|
||||
case type::error:
|
||||
return d_->string_value;
|
||||
case type::null:
|
||||
return "";
|
||||
case type::boolean:
|
||||
return d_->numeric_value != 0 ? "TRUE" : "FALSE";
|
||||
default:
|
||||
throw std::runtime_error("bad enum");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,7 +125,7 @@ cell::type cell::data_type_for_value(const std::string &value)
|
|||
return type::string;
|
||||
}
|
||||
}
|
||||
return type::date;
|
||||
return type::numeric;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -172,24 +160,44 @@ cell::type cell::data_type_for_value(const std::string &value)
|
|||
|
||||
void cell::set_explicit_value(const std::string &value, type data_type)
|
||||
{
|
||||
d_->type_ = (cell_impl::type)data_type;
|
||||
d_->type_ = data_type;
|
||||
|
||||
switch(data_type)
|
||||
{
|
||||
case type::formula: d_->formula_value = value; return;
|
||||
case type::date: d_->date_value.tm_hour = std::stoi(value); return;
|
||||
case type::error: d_->error_value = value; return;
|
||||
case type::boolean: d_->numeric_value = value == "true"; return;
|
||||
case type::null: return;
|
||||
case type::formula: d_->string_value = value; return;
|
||||
case type::error: d_->string_value = value; return;
|
||||
case type::boolean: d_->numeric_value = value == "true"; return;
|
||||
case type::numeric: d_->numeric_value = std::stod(value); return;
|
||||
case type::string: d_->string_value = value; return;
|
||||
default: throw std::runtime_error("bad enum");
|
||||
}
|
||||
}
|
||||
|
||||
void cell::set_hyperlink(const std::string &url)
|
||||
void cell::set_explicit_value(int value, type data_type)
|
||||
{
|
||||
d_->type_ = cell_impl::type::hyperlink;
|
||||
d_->string_value = url;
|
||||
d_->type_ = data_type;
|
||||
|
||||
switch(data_type)
|
||||
{
|
||||
case type::null: return;
|
||||
case type::numeric: d_->numeric_value = value; return;
|
||||
case type::string: d_->string_value = std::to_string(value); return;
|
||||
default: throw std::runtime_error("bad enum");
|
||||
}
|
||||
}
|
||||
|
||||
void cell::set_explicit_value(double value, type data_type)
|
||||
{
|
||||
d_->type_ = data_type;
|
||||
|
||||
switch(data_type)
|
||||
{
|
||||
case type::null: return;
|
||||
case type::numeric: d_->numeric_value = value; return;
|
||||
case type::string: d_->string_value = std::to_string(value); return;
|
||||
default: throw std::runtime_error("bad enum");
|
||||
}
|
||||
}
|
||||
|
||||
void cell::set_merged(bool merged)
|
||||
|
@ -202,55 +210,9 @@ bool cell::is_merged() const
|
|||
return d_->merged;
|
||||
}
|
||||
|
||||
bool cell::bind_value()
|
||||
{
|
||||
d_->type_ = cell_impl::type::null;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cell::bind_value(int value)
|
||||
{
|
||||
d_->type_ = cell_impl::type::numeric;
|
||||
d_->numeric_value = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cell::bind_value(double value)
|
||||
{
|
||||
d_->type_ = cell_impl::type::numeric;
|
||||
d_->numeric_value = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cell::bind_value(const std::string &value)
|
||||
{
|
||||
//Given a value, infer type and display options.
|
||||
d_->type_ = (cell_impl::type)data_type_for_value(value);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cell::bind_value(const char *value)
|
||||
{
|
||||
return bind_value(std::string(value));
|
||||
}
|
||||
|
||||
bool cell::bind_value(bool value)
|
||||
{
|
||||
d_->type_ = cell_impl::type::boolean;
|
||||
d_->numeric_value = value ? 1 : 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cell::bind_value(const tm &value)
|
||||
{
|
||||
d_->type_ = cell_impl::type::date;
|
||||
d_->date_value = value;
|
||||
return true;
|
||||
}
|
||||
|
||||
bool cell::is_date() const
|
||||
{
|
||||
return d_->type_ == cell_impl::type::date;
|
||||
return d_->is_date_;
|
||||
}
|
||||
|
||||
cell_reference cell::get_reference() const
|
||||
|
@ -258,11 +220,6 @@ cell_reference cell::get_reference() const
|
|||
return {d_->column, d_->row};
|
||||
}
|
||||
|
||||
std::string cell::get_hyperlink_rel_id() const
|
||||
{
|
||||
return d_->hyperlink_rel.get_id();
|
||||
}
|
||||
|
||||
bool cell::operator==(std::nullptr_t) const
|
||||
{
|
||||
return d_ == nullptr;
|
||||
|
@ -270,21 +227,17 @@ bool cell::operator==(std::nullptr_t) const
|
|||
|
||||
bool cell::operator==(int comparand) const
|
||||
{
|
||||
return d_->type_ == cell_impl::type::numeric && d_->numeric_value == comparand;
|
||||
return d_->type_ == type::numeric && d_->numeric_value == comparand;
|
||||
}
|
||||
|
||||
bool cell::operator==(double comparand) const
|
||||
{
|
||||
return d_->type_ == cell_impl::type::numeric && d_->numeric_value == comparand;
|
||||
return d_->type_ == type::numeric && d_->numeric_value == comparand;
|
||||
}
|
||||
|
||||
bool cell::operator==(const std::string &comparand) const
|
||||
{
|
||||
if(d_->type_ == cell_impl::type::hyperlink)
|
||||
{
|
||||
return d_->hyperlink_rel.get_target_uri() == comparand;
|
||||
}
|
||||
if(d_->type_ == cell_impl::type::string)
|
||||
if(d_->type_ == type::string)
|
||||
{
|
||||
return d_->string_value == comparand;
|
||||
}
|
||||
|
@ -296,9 +249,19 @@ bool cell::operator==(const char *comparand) const
|
|||
return *this == std::string(comparand);
|
||||
}
|
||||
|
||||
bool cell::operator==(const tm &comparand) const
|
||||
bool cell::operator==(const time &comparand) const
|
||||
{
|
||||
return d_->type_ == cell_impl::type::date && d_->date_value.tm_hour == comparand.tm_hour;
|
||||
return d_->type_ == type::numeric && time(d_->numeric_value).hour == comparand.hour;
|
||||
}
|
||||
|
||||
bool cell::operator==(const date &comparand) const
|
||||
{
|
||||
return d_->type_ == type::numeric && date((int)d_->numeric_value, 0, 0).year == comparand.year;
|
||||
}
|
||||
|
||||
bool cell::operator==(const datetime &comparand) const
|
||||
{
|
||||
return d_->type_ == type::numeric && datetime((int)d_->numeric_value, 0, 0).year == comparand.year;
|
||||
}
|
||||
|
||||
bool operator==(int comparand, const xlnt::cell &cell)
|
||||
|
@ -316,7 +279,17 @@ bool operator==(const std::string &comparand, const xlnt::cell &cell)
|
|||
return cell == comparand;
|
||||
}
|
||||
|
||||
bool operator==(const tm &comparand, const xlnt::cell &cell)
|
||||
bool operator==(const time &comparand, const xlnt::cell &cell)
|
||||
{
|
||||
return cell == comparand;
|
||||
}
|
||||
|
||||
bool operator==(const date &comparand, const xlnt::cell &cell)
|
||||
{
|
||||
return cell == comparand;
|
||||
}
|
||||
|
||||
bool operator==(const datetime &comparand, const xlnt::cell &cell)
|
||||
{
|
||||
return cell == comparand;
|
||||
}
|
||||
|
@ -352,21 +325,21 @@ cell &cell::operator=(const cell &rhs)
|
|||
|
||||
cell &cell::operator=(int value)
|
||||
{
|
||||
d_->type_ = cell_impl::type::numeric;
|
||||
d_->type_ = type::numeric;
|
||||
d_->numeric_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
cell &cell::operator=(double value)
|
||||
{
|
||||
d_->type_ = cell_impl::type::numeric;
|
||||
d_->type_ = type::numeric;
|
||||
d_->numeric_value = value;
|
||||
return *this;
|
||||
}
|
||||
|
||||
cell &cell::operator=(bool value)
|
||||
{
|
||||
d_->type_ = cell_impl::type::boolean;
|
||||
d_->type_ = type::boolean;
|
||||
d_->numeric_value = value ? 1 : 0;
|
||||
return *this;
|
||||
}
|
||||
|
@ -374,24 +347,12 @@ cell &cell::operator=(bool value)
|
|||
|
||||
cell &cell::operator=(const std::string &value)
|
||||
{
|
||||
d_->type_ = (cell_impl::type)data_type_for_value(value);
|
||||
d_->type_ = data_type_for_value(value);
|
||||
|
||||
switch((type)d_->type_)
|
||||
{
|
||||
case type::date:
|
||||
{
|
||||
d_->date_value = std::tm();
|
||||
auto split = split_string(value, ':');
|
||||
d_->date_value.tm_hour = std::stoi(split[0]);
|
||||
d_->date_value.tm_min = std::stoi(split[1]);
|
||||
if(split.size() > 2)
|
||||
{
|
||||
d_->date_value.tm_sec = std::stoi(split[2]);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case type::formula:
|
||||
d_->formula_value = value;
|
||||
d_->string_value = value;
|
||||
break;
|
||||
case type::numeric:
|
||||
d_->numeric_value = std::stod(value);
|
||||
|
@ -400,7 +361,7 @@ cell &cell::operator=(const std::string &value)
|
|||
d_->numeric_value = value == "TRUE" || value == "true";
|
||||
break;
|
||||
case type::error:
|
||||
d_->error_value = value;
|
||||
d_->string_value = value;
|
||||
break;
|
||||
case type::string:
|
||||
d_->string_value = value;
|
||||
|
@ -419,10 +380,24 @@ cell &cell::operator=(const char *value)
|
|||
return *this = std::string(value);
|
||||
}
|
||||
|
||||
cell &cell::operator=(const tm &value)
|
||||
cell &cell::operator=(const time &value)
|
||||
{
|
||||
d_->type_ = cell_impl::type::date;
|
||||
d_->date_value = value;
|
||||
d_->type_ = type::numeric;
|
||||
d_->numeric_value = value.hour;
|
||||
return *this;
|
||||
}
|
||||
|
||||
cell &cell::operator=(const date &value)
|
||||
{
|
||||
d_->type_ = type::numeric;
|
||||
d_->numeric_value = value.year;
|
||||
return *this;
|
||||
}
|
||||
|
||||
cell &cell::operator=(const datetime &value)
|
||||
{
|
||||
d_->type_ = type::numeric;
|
||||
d_->numeric_value = value.year;
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
@ -431,5 +406,31 @@ std::string cell::to_string() const
|
|||
return "<Cell " + cell_reference(d_->column, d_->row).to_string() + ">";
|
||||
}
|
||||
|
||||
} // namespace xlnt
|
||||
std::string cell::get_hyperlink() const
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
void cell::set_hyperlink(const std::string &/*hyperlink*/)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void cell::set_null()
|
||||
{
|
||||
d_->type_ = type::null;
|
||||
}
|
||||
|
||||
void cell::set_formula(const std::string &formula)
|
||||
{
|
||||
d_->type_ = type::formula;
|
||||
d_->string_value = formula;
|
||||
}
|
||||
|
||||
void cell::set_error(const std::string &error)
|
||||
{
|
||||
d_->type_ = type::error;
|
||||
d_->string_value = error;
|
||||
}
|
||||
|
||||
} // namespace xlnt
|
||||
|
|
|
@ -1,42 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
#include "types.h"
|
||||
#include "relationship.h"
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
class style;
|
||||
|
||||
struct cell_impl
|
||||
{
|
||||
cell_impl();
|
||||
cell_impl(int column_index, int row_index);
|
||||
|
||||
std::string to_string() const;
|
||||
|
||||
enum class type
|
||||
{
|
||||
null,
|
||||
numeric,
|
||||
string,
|
||||
date,
|
||||
formula,
|
||||
boolean,
|
||||
error,
|
||||
hyperlink
|
||||
};
|
||||
|
||||
type type_;
|
||||
long double numeric_value;
|
||||
std::string error_value;
|
||||
tm date_value;
|
||||
std::string string_value;
|
||||
std::string formula_value;
|
||||
column_t column;
|
||||
row_t row;
|
||||
style *style_;
|
||||
relationship hyperlink_rel;
|
||||
bool merged;
|
||||
};
|
||||
|
||||
}
|
|
@ -42,7 +42,7 @@ absolute_(absolute)
|
|||
{
|
||||
if(row == 0 || row_index_ >= constants::MaxRow || column_index_ >= constants::MaxColumn)
|
||||
{
|
||||
throw bad_cell_coordinates(column_index_, row_index_);
|
||||
throw cell_coordinates_exception(column_index_, row_index_);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@ absolute_(absolute)
|
|||
{
|
||||
if(row_index_ >= constants::MaxRow || column_index_ >= constants::MaxColumn)
|
||||
{
|
||||
throw bad_cell_coordinates(column_index_, row_index_);
|
||||
throw cell_coordinates_exception(column_index_, row_index_);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,7 +93,7 @@ std::pair<std::string, row_t> cell_reference::split_reference(const std::string
|
|||
}
|
||||
else
|
||||
{
|
||||
throw bad_cell_coordinates(reference_string);
|
||||
throw cell_coordinates_exception(reference_string);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -104,7 +104,7 @@ std::pair<std::string, row_t> cell_reference::split_reference(const std::string
|
|||
}
|
||||
else if(!(std::isdigit(character, std::locale::classic()) || character == '$'))
|
||||
{
|
||||
throw bad_cell_coordinates(reference_string);
|
||||
throw cell_coordinates_exception(reference_string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -8,13 +8,13 @@ bad_sheet_title::bad_sheet_title(const std::string &title)
|
|||
|
||||
}
|
||||
|
||||
bad_cell_coordinates::bad_cell_coordinates(int row, int column)
|
||||
cell_coordinates_exception::cell_coordinates_exception(int row, int column)
|
||||
: std::runtime_error(std::string("bad cell coordinates: (") + std::to_string(row) + "," + std::to_string(column) + ")")
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bad_cell_coordinates::bad_cell_coordinates(const std::string &coord_string)
|
||||
cell_coordinates_exception::cell_coordinates_exception(const std::string &coord_string)
|
||||
: std::runtime_error(std::string("bad cell coordinates: (") + coord_string + ")")
|
||||
{
|
||||
|
||||
|
|
29
source/datetime.cpp
Normal file
29
source/datetime.cpp
Normal file
|
@ -0,0 +1,29 @@
|
|||
#include <cmath>
|
||||
#include <ctime>
|
||||
|
||||
#include "datetime.h"
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
time::time(long double raw_time)
|
||||
{
|
||||
double integer_part;
|
||||
double fractional_part = std::modf(raw_time, &integer_part);
|
||||
fractional_part *= 24;
|
||||
hour = (int)fractional_part;
|
||||
fractional_part = 60 * (fractional_part - hour);
|
||||
minute = (int)fractional_part;
|
||||
fractional_part = 60 * (fractional_part - minute);
|
||||
second = (int)fractional_part;
|
||||
fractional_part = 1000000 * (fractional_part - second);
|
||||
microsecond = (int)fractional_part;
|
||||
}
|
||||
|
||||
datetime datetime::now()
|
||||
{
|
||||
std::time_t raw_time = std::time(0);
|
||||
std::tm now = *std::localtime(&raw_time);
|
||||
return datetime(now.tm_year, now.tm_mon + 1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec);
|
||||
}
|
||||
|
||||
} // namespace xlnt
|
15
source/detail/cell_impl.cpp
Normal file
15
source/detail/cell_impl.cpp
Normal file
|
@ -0,0 +1,15 @@
|
|||
#include "cell_impl.h"
|
||||
|
||||
namespace xlnt {
|
||||
namespace detail {
|
||||
|
||||
cell_impl::cell_impl() : type_(cell::type::null), column(0), row(0)
|
||||
{
|
||||
}
|
||||
|
||||
cell_impl::cell_impl(int column_index, int row_index) : type_(cell::type::null), column(column_index), row(row_index)
|
||||
{
|
||||
}
|
||||
|
||||
} // namespace detail
|
||||
} // namespace xlnt
|
29
source/detail/cell_impl.h
Normal file
29
source/detail/cell_impl.h
Normal file
|
@ -0,0 +1,29 @@
|
|||
#pragma once
|
||||
|
||||
#include "cell.h"
|
||||
#include "types.h"
|
||||
#include "relationship.h"
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
class style;
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct cell_impl
|
||||
{
|
||||
cell_impl();
|
||||
cell_impl(int column_index, int row_index);
|
||||
|
||||
cell::type type_;
|
||||
long double numeric_value;
|
||||
std::string string_value;
|
||||
column_t column;
|
||||
row_t row;
|
||||
bool merged;
|
||||
style *style_;
|
||||
bool is_date_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace xlnt
|
|
@ -1,10 +1,15 @@
|
|||
#pragma once
|
||||
|
||||
#include <vector>
|
||||
|
||||
namespace xlnt {
|
||||
namespace detail {
|
||||
|
||||
struct workbook_impl
|
||||
{
|
||||
workbook_impl(optimization o);
|
||||
bool optimized_write_;
|
||||
bool optimized_read_;
|
||||
bool optimized_write_;
|
||||
bool guess_types_;
|
||||
bool data_only_;
|
||||
int active_sheet_index_;
|
||||
|
@ -13,4 +18,5 @@ struct workbook_impl
|
|||
std::vector<drawing> drawings_;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
} // namespace xlnt
|
|
@ -4,10 +4,12 @@
|
|||
|
||||
#include "cell_impl.h"
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
class workbook;
|
||||
|
||||
namespace detail {
|
||||
|
||||
struct worksheet_impl
|
||||
{
|
||||
worksheet_impl(workbook *parent_workbook, const std::string &title)
|
||||
|
@ -46,4 +48,5 @@ struct worksheet_impl
|
|||
std::unordered_map<std::string, range_reference> named_ranges_;
|
||||
};
|
||||
|
||||
} // namespace xlnt
|
||||
} // namespace detail
|
||||
} // namespace xlnt
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "reader.h"
|
||||
#include "cell.h"
|
||||
#include "datetime.h"
|
||||
#include "range_reference.h"
|
||||
#include "workbook.h"
|
||||
#include "worksheet.h"
|
||||
|
@ -137,50 +138,48 @@ void read_worksheet_common(worksheet ws, const pugi::xml_node &root_node, const
|
|||
}
|
||||
else if(cell_node.attribute("s") != nullptr && std::string(cell_node.attribute("s").as_string()) == "2") // date
|
||||
{
|
||||
tm date = tm();
|
||||
date.tm_year = 1900;
|
||||
date date(1900, 1, 1);
|
||||
int days = cell_node.child("v").text().as_int();
|
||||
while(days > 365)
|
||||
{
|
||||
date.tm_year += 1;
|
||||
date.year += 1;
|
||||
days -= 365;
|
||||
}
|
||||
date.tm_yday = days;
|
||||
while(days > 30)
|
||||
{
|
||||
date.tm_mon += 1;
|
||||
date.month += 1;
|
||||
days -= 30;
|
||||
}
|
||||
date.tm_mday = days;
|
||||
date.day = days;
|
||||
ws.get_cell(address) = date;
|
||||
}
|
||||
else if(cell_node.attribute("s") != nullptr && std::string(cell_node.attribute("s").as_string()) == "3") // time
|
||||
{
|
||||
tm date;
|
||||
time time;
|
||||
double remaining = cell_node.child("v").text().as_double() * 24;
|
||||
date.tm_hour = (int)(remaining);
|
||||
remaining -= date.tm_hour;
|
||||
time.hour = (int)(remaining);
|
||||
remaining -= time.hour;
|
||||
remaining *= 60;
|
||||
date.tm_min = (int)(remaining);
|
||||
remaining -= date.tm_min;
|
||||
time.minute = (int)(remaining);
|
||||
remaining -= time.minute;
|
||||
remaining *= 60;
|
||||
date.tm_sec = (int)(remaining);
|
||||
remaining -= date.tm_sec;
|
||||
time.second = (int)(remaining);
|
||||
remaining -= time.second;
|
||||
if(remaining > 0.5)
|
||||
{
|
||||
date.tm_sec++;
|
||||
if(date.tm_sec > 59)
|
||||
time.second++;
|
||||
if(time.second > 59)
|
||||
{
|
||||
date.tm_sec = 0;
|
||||
date.tm_min++;
|
||||
if(date.tm_min > 59)
|
||||
time.second = 0;
|
||||
time.minute++;
|
||||
if(time.minute > 59)
|
||||
{
|
||||
date.tm_min = 0;
|
||||
date.tm_hour++;
|
||||
time.minute = 0;
|
||||
time.hour++;
|
||||
}
|
||||
}
|
||||
}
|
||||
ws.get_cell(address) = date;
|
||||
ws.get_cell(address) = time;
|
||||
}
|
||||
else if(cell_node.attribute("s") != nullptr && std::string(cell_node.attribute("s").as_string()) == "4") // decimal
|
||||
{
|
||||
|
|
|
@ -3,26 +3,27 @@
|
|||
#include <pugixml.hpp>
|
||||
|
||||
#include "workbook.h"
|
||||
#include "cell_impl.h"
|
||||
#include "custom_exceptions.h"
|
||||
#include "drawing.h"
|
||||
#include "range.h"
|
||||
#include "reader.h"
|
||||
#include "relationship.h"
|
||||
#include "workbook_impl.h"
|
||||
#include "worksheet.h"
|
||||
#include "worksheet_impl.h"
|
||||
#include "writer.h"
|
||||
#include "zip_file.h"
|
||||
#include "detail/cell_impl.h"
|
||||
#include "detail/workbook_impl.h"
|
||||
#include "detail/worksheet_impl.h"
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
namespace detail {
|
||||
workbook_impl::workbook_impl(optimization o) : optimized_read_(o == optimization::read), optimized_write_(o == optimization::write), active_sheet_index_(0)
|
||||
{
|
||||
|
||||
}
|
||||
} // namespace detail
|
||||
|
||||
workbook::workbook(optimization optimize) : d_(new workbook_impl(optimize))
|
||||
workbook::workbook(optimization optimize) : d_(new detail::workbook_impl(optimize))
|
||||
{
|
||||
if(!d_->optimized_read_)
|
||||
{
|
||||
|
@ -93,7 +94,7 @@ bool workbook::const_iterator::operator==(const const_iterator &comparand) const
|
|||
|
||||
worksheet workbook::get_sheet_by_name(const std::string &name)
|
||||
{
|
||||
auto title_equals = [&](worksheet_impl &ws) { return worksheet(&ws).get_title() == name; };
|
||||
auto title_equals = [&](detail::worksheet_impl &ws) { return worksheet(&ws).get_title() == name; };
|
||||
auto match = std::find_if(d_->worksheets_.begin(), d_->worksheets_.end(), title_equals);
|
||||
|
||||
if(match != d_->worksheets_.end())
|
||||
|
@ -171,7 +172,7 @@ void workbook::add_sheet(xlnt::worksheet worksheet)
|
|||
void workbook::add_sheet(xlnt::worksheet worksheet, std::size_t index)
|
||||
{
|
||||
add_sheet(worksheet);
|
||||
// std::swap(d_->worksheets_[index], d_->worksheets_.back());
|
||||
std::swap(d_->worksheets_[index], d_->worksheets_.back());
|
||||
}
|
||||
|
||||
int workbook::get_index(xlnt::worksheet worksheet)
|
||||
|
@ -269,7 +270,7 @@ void workbook::load(const std::string &filename)
|
|||
|
||||
void workbook::remove_sheet(worksheet ws)
|
||||
{
|
||||
auto match_iter = std::find_if(d_->worksheets_.begin(), d_->worksheets_.end(), [=](worksheet_impl &comp) { return worksheet(&comp) == ws; });
|
||||
auto match_iter = std::find_if(d_->worksheets_.begin(), d_->worksheets_.end(), [=](detail::worksheet_impl &comp) { return worksheet(&comp) == ws; });
|
||||
|
||||
if(match_iter == d_->worksheets_.end())
|
||||
{
|
||||
|
@ -313,7 +314,7 @@ worksheet workbook::create_sheet(const std::string &title)
|
|||
throw bad_sheet_title(title);
|
||||
}
|
||||
|
||||
if(std::find_if(d_->worksheets_.begin(), d_->worksheets_.end(), [&](worksheet_impl &ws) { return worksheet(&ws).get_title() == title; }) != d_->worksheets_.end())
|
||||
if(std::find_if(d_->worksheets_.begin(), d_->worksheets_.end(), [&](detail::worksheet_impl &ws) { return worksheet(&ws).get_title() == title; }) != d_->worksheets_.end())
|
||||
{
|
||||
throw std::runtime_error("sheet exists");
|
||||
}
|
||||
|
|
|
@ -2,11 +2,12 @@
|
|||
|
||||
#include "worksheet.h"
|
||||
#include "cell.h"
|
||||
#include "datetime.h"
|
||||
#include "range.h"
|
||||
#include "range_reference.h"
|
||||
#include "relationship.h"
|
||||
#include "workbook.h"
|
||||
#include "worksheet_impl.h"
|
||||
#include "detail/worksheet_impl.h"
|
||||
|
||||
namespace xlnt {
|
||||
|
||||
|
@ -15,7 +16,7 @@ worksheet::worksheet() : d_(nullptr)
|
|||
|
||||
}
|
||||
|
||||
worksheet::worksheet(worksheet_impl *d) : d_(d)
|
||||
worksheet::worksheet(detail::worksheet_impl *d) : d_(d)
|
||||
{
|
||||
|
||||
}
|
||||
|
@ -169,14 +170,14 @@ cell worksheet::get_cell(const cell_reference &reference)
|
|||
{
|
||||
if(d_->cell_map_.find(reference.get_row_index()) == d_->cell_map_.end())
|
||||
{
|
||||
d_->cell_map_[reference.get_row_index()] = std::unordered_map<int, cell_impl>();
|
||||
d_->cell_map_[reference.get_row_index()] = std::unordered_map<int, detail::cell_impl>();
|
||||
}
|
||||
|
||||
auto &row = d_->cell_map_[reference.get_row_index()];
|
||||
|
||||
if(row.find(reference.get_column_index()) == row.end())
|
||||
{
|
||||
row[reference.get_column_index()] = cell_impl(reference.get_column_index(), reference.get_row_index());
|
||||
row[reference.get_column_index()] = detail::cell_impl(reference.get_column_index(), reference.get_row_index());
|
||||
}
|
||||
|
||||
return cell(&row[reference.get_column_index()]);
|
||||
|
@ -306,7 +307,7 @@ void worksheet::merge_cells(const range_reference &reference)
|
|||
cell.set_merged(true);
|
||||
if(!first)
|
||||
{
|
||||
cell.bind_value();
|
||||
cell.set_null();
|
||||
}
|
||||
first = false;
|
||||
}
|
||||
|
@ -350,6 +351,40 @@ void worksheet::append(const std::vector<std::string> &cells)
|
|||
}
|
||||
}
|
||||
|
||||
void worksheet::append(const std::vector<int> &cells)
|
||||
{
|
||||
int row = get_highest_row();
|
||||
|
||||
if(d_->cell_map_.size() == 0)
|
||||
{
|
||||
row--;
|
||||
}
|
||||
|
||||
int column = 0;
|
||||
|
||||
for(auto cell : cells)
|
||||
{
|
||||
this->get_cell(cell_reference(column++, row)) = cell;
|
||||
}
|
||||
}
|
||||
|
||||
void worksheet::append(const std::vector<date> &cells)
|
||||
{
|
||||
int row = get_highest_row();
|
||||
|
||||
if(d_->cell_map_.size() == 0)
|
||||
{
|
||||
row--;
|
||||
}
|
||||
|
||||
int column = 0;
|
||||
|
||||
for(auto cell : cells)
|
||||
{
|
||||
this->get_cell(cell_reference(column++, row)) = cell;
|
||||
}
|
||||
}
|
||||
|
||||
void worksheet::append(const std::unordered_map<std::string, std::string> &cells)
|
||||
{
|
||||
int row = get_highest_row() - 1;
|
||||
|
|
|
@ -22,12 +22,12 @@ public:
|
|||
|
||||
void test_invalid_coordinate()
|
||||
{
|
||||
TS_ASSERT_THROWS_ANYTHING(xlnt::cell_reference("AAA"));
|
||||
TS_ASSERT_THROWS(xlnt::cell_reference("AAA"), xlnt::cell_coordinates_exception);
|
||||
}
|
||||
|
||||
void test_zero_row()
|
||||
{
|
||||
TS_ASSERT_THROWS_ANYTHING(xlnt::cell_reference("AQ0"));
|
||||
TS_ASSERT_THROWS(xlnt::cell_reference("AQ0"), xlnt::cell_coordinates_exception);
|
||||
}
|
||||
|
||||
void test_absolute()
|
||||
|
@ -44,29 +44,29 @@ public:
|
|||
{
|
||||
static const std::unordered_map<int, std::string> expected =
|
||||
{
|
||||
{10, "J"},
|
||||
{270, "jJ"},
|
||||
{7030, "jjj"},
|
||||
{1, "A"},
|
||||
{10, "J"},
|
||||
{26, "Z"},
|
||||
{27, "AA"},
|
||||
{52, "AZ"},
|
||||
{53, "BA"},
|
||||
{78, "BZ"},
|
||||
{270, "jJ"},
|
||||
{677, "ZA"},
|
||||
{702, "ZZ"},
|
||||
{703, "AAA"},
|
||||
{728, "AAZ"},
|
||||
{731, "ABC"},
|
||||
{1353, "AZA"},
|
||||
{7030, "jjj"},
|
||||
{18253, "ZZA"},
|
||||
{18278, "ZZZ"}
|
||||
};
|
||||
|
||||
for(auto expected_pair : expected)
|
||||
{
|
||||
auto calculated = xlnt::cell_reference::column_index_from_string(expected_pair.second);
|
||||
TS_ASSERT_EQUALS(expected_pair.first, calculated);
|
||||
TS_ASSERT_EQUALS(expected_pair.first,
|
||||
xlnt::cell_reference::column_index_from_string(expected_pair.second));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -74,14 +74,17 @@ public:
|
|||
{
|
||||
for(auto bad_string : {"JJJJ", "", "$", "1"})
|
||||
{
|
||||
TS_ASSERT_THROWS_ANYTHING(xlnt::cell_reference::column_index_from_string(bad_string));
|
||||
TS_ASSERT_THROWS(xlnt::cell_reference::column_index_from_string(bad_string),
|
||||
xlnt::column_string_index_exception);
|
||||
}
|
||||
}
|
||||
|
||||
void test_column_letter_boundries()
|
||||
{
|
||||
TS_ASSERT_THROWS_ANYTHING(xlnt::cell_reference::column_string_from_index(0));
|
||||
TS_ASSERT_THROWS_ANYTHING(xlnt::cell_reference::column_string_from_index(18279));
|
||||
TS_ASSERT_THROWS(xlnt::cell_reference::column_string_from_index(0),
|
||||
xlnt::column_string_index_exception);
|
||||
TS_ASSERT_THROWS(xlnt::cell_reference::column_string_from_index(18279),
|
||||
xlnt::column_string_index_exception);
|
||||
}
|
||||
|
||||
|
||||
|
@ -97,8 +100,7 @@ public:
|
|||
|
||||
void test_initial_value()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
xlnt::worksheet ws = wb.create_sheet();
|
||||
xlnt::cell cell(ws, "A1", "17.5");
|
||||
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
|
||||
|
@ -106,8 +108,7 @@ public:
|
|||
|
||||
void test_null()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
xlnt::worksheet ws = wb.create_sheet();
|
||||
xlnt::cell cell(ws, "A1");
|
||||
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::null, cell.get_data_type());
|
||||
|
@ -115,40 +116,49 @@ public:
|
|||
|
||||
void test_numeric()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
xlnt::cell cell(ws, "A1", "17.5");
|
||||
xlnt::worksheet ws = wb.create_sheet();
|
||||
xlnt::cell cell(ws, "A1");
|
||||
|
||||
cell = 42;
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
|
||||
|
||||
cell = "4.2";
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
|
||||
|
||||
cell = "-42.000";
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
|
||||
|
||||
cell = "0";
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
|
||||
|
||||
cell = 0;
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
|
||||
|
||||
cell = 0.0001;
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
|
||||
|
||||
cell = "0.9999";
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
|
||||
|
||||
cell = "99E-02";
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
|
||||
|
||||
cell = 1e1;
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
|
||||
|
||||
cell = "4";
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
|
||||
|
||||
cell = "-1E3";
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
|
||||
|
||||
cell = 4;
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
|
||||
}
|
||||
|
||||
void test_string()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
xlnt::worksheet ws = wb.create_sheet();
|
||||
xlnt::cell cell(ws, "A1");
|
||||
|
||||
cell = "hello";
|
||||
|
@ -157,8 +167,7 @@ public:
|
|||
|
||||
void test_single_dot()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
xlnt::worksheet ws = wb.create_sheet();
|
||||
xlnt::cell cell(ws, "A1");
|
||||
cell = ".";
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::string, cell.get_data_type());
|
||||
|
@ -166,8 +175,7 @@ public:
|
|||
|
||||
void test_formula()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
xlnt::worksheet ws = wb.create_sheet();
|
||||
xlnt::cell cell(ws, "A1");
|
||||
cell = "=42";
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::formula, cell.get_data_type());
|
||||
|
@ -175,8 +183,7 @@ public:
|
|||
|
||||
void test_boolean()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
xlnt::worksheet ws = wb.create_sheet();
|
||||
xlnt::cell cell(ws, "A1");
|
||||
cell = true;
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::boolean, cell.get_data_type());
|
||||
|
@ -186,8 +193,7 @@ public:
|
|||
|
||||
void test_leading_zero()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
xlnt::worksheet ws = wb.create_sheet();
|
||||
xlnt::cell cell(ws, "A1");
|
||||
cell = "0800";
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::string, cell.get_data_type());
|
||||
|
@ -195,8 +201,7 @@ public:
|
|||
|
||||
void test_error_codes()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
xlnt::worksheet ws = wb.create_sheet();
|
||||
xlnt::cell cell(ws, "A1");
|
||||
|
||||
for(auto error : xlnt::cell::ErrorCodes)
|
||||
|
@ -209,79 +214,68 @@ public:
|
|||
|
||||
void test_data_type_check()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
xlnt::worksheet ws = wb.create_sheet();
|
||||
xlnt::cell cell(ws, "A1");
|
||||
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::null, cell.get_data_type());
|
||||
|
||||
cell.bind_value(".0e000");
|
||||
cell = ".0e000";
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
|
||||
|
||||
cell.bind_value("-0.e-0");
|
||||
cell = "-0.e-0";
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
|
||||
|
||||
cell.bind_value("1E");
|
||||
cell = "1E";
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::string, cell.get_data_type());
|
||||
}
|
||||
|
||||
void test_set_bad_type()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
xlnt::worksheet ws = wb.create_sheet();
|
||||
xlnt::cell cell(ws, "A1");
|
||||
|
||||
cell.set_explicit_value("1", xlnt::cell::type::formula);
|
||||
TS_ASSERT_THROWS(cell.set_explicit_value("1", xlnt::cell::type::formula),
|
||||
xlnt::data_type_exception);
|
||||
TS_ASSERT_THROWS(cell.set_explicit_value(1, xlnt::cell::type::formula),
|
||||
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_hyperlink("1"), xlnt::data_type_exception);
|
||||
TS_ASSERT_THROWS(cell.set_formula("#REF!"), xlnt::data_type_exception);
|
||||
}
|
||||
|
||||
|
||||
void test_time()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
xlnt::worksheet ws = wb.create_sheet();
|
||||
xlnt::cell cell(ws, "A1");
|
||||
|
||||
cell = "03:40:16";
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::date, cell.get_data_type());
|
||||
tm expected1;
|
||||
expected1.tm_hour = 3;
|
||||
expected1.tm_min = 40;
|
||||
expected1.tm_sec = 16;
|
||||
TS_ASSERT(cell == expected1);
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
|
||||
TS_ASSERT(cell == xlnt::time(3, 40, 16));
|
||||
|
||||
cell = "03:40";
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::date, cell.get_data_type());
|
||||
tm expected2;
|
||||
expected2.tm_hour = 3;
|
||||
expected2.tm_min = 40;
|
||||
TS_ASSERT(cell == expected1);
|
||||
TS_ASSERT_EQUALS(xlnt::cell::type::numeric, cell.get_data_type());
|
||||
TS_ASSERT(cell == xlnt::time(3, 40));
|
||||
}
|
||||
|
||||
void test_date_format_on_non_date()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
xlnt::worksheet ws = wb.create_sheet();
|
||||
xlnt::cell cell(ws, "A1");
|
||||
|
||||
time_t t = time(0);
|
||||
tm now = *localtime(&t);
|
||||
cell = now;
|
||||
cell = xlnt::datetime::now();
|
||||
cell = "testme";
|
||||
TS_ASSERT("testme" == cell);
|
||||
}
|
||||
|
||||
void test_set_get_date()
|
||||
{
|
||||
tm today = {0};
|
||||
today.tm_year = 2010;
|
||||
today.tm_mon = 1;
|
||||
today.tm_yday = 18;
|
||||
today.tm_hour = 14;
|
||||
today.tm_min = 15;
|
||||
today.tm_sec = 20;
|
||||
xlnt::datetime today(2010, 1, 18, 14,15, 20 ,1600);
|
||||
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
xlnt::worksheet ws = wb.create_sheet();
|
||||
xlnt::cell cell(ws, "A1");
|
||||
|
||||
cell = today;
|
||||
|
@ -290,39 +284,37 @@ public:
|
|||
|
||||
void test_repr()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
xlnt::worksheet ws = wb.create_sheet();
|
||||
xlnt::cell cell(ws, "A1");
|
||||
|
||||
TS_ASSERT_EQUALS(cell.to_string(), "<Cell A1>");
|
||||
TS_ASSERT_EQUALS(cell.to_string(), "<Cell " + ws.get_title() + ".A1>");
|
||||
}
|
||||
|
||||
void test_is_date()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
xlnt::worksheet ws = wb.create_sheet();
|
||||
xlnt::cell cell(ws, "A1");
|
||||
|
||||
time_t t = time(0);
|
||||
tm now = *localtime(&t);
|
||||
cell = now;
|
||||
TS_ASSERT_EQUALS(cell.is_date(), true);
|
||||
cell = xlnt::datetime::now();
|
||||
TS_ASSERT(cell.is_date());
|
||||
|
||||
cell = "testme";
|
||||
TS_ASSERT_EQUALS("testme", cell);
|
||||
TS_ASSERT_EQUALS(cell.is_date(), false);
|
||||
TS_ASSERT(!cell.is_date());
|
||||
}
|
||||
|
||||
|
||||
void test_is_not_date_color_format()
|
||||
{
|
||||
xlnt::workbook wb;
|
||||
xlnt::worksheet ws = wb.get_active_sheet();
|
||||
xlnt::worksheet ws = wb.create_sheet();
|
||||
xlnt::cell cell(ws, "A1");
|
||||
|
||||
cell = -13.5;
|
||||
//cell.get_style().get_number_format().set_format_code("0.00_);[Red]\\(0.00\\)");
|
||||
cell.get_style().get_number_format().set_format_code("0.00_);[Red]\\(0.00\\)");
|
||||
|
||||
TS_ASSERT_EQUALS(cell.is_date(), false);
|
||||
TS_ASSERT(!cell.is_date());
|
||||
}
|
||||
|
||||
private:
|
||||
xlnt::workbook wb;
|
||||
};
|
||||
|
|
|
@ -9,16 +9,13 @@
|
|||
class DumpTestSuite : public CxxTest::TestSuite
|
||||
{
|
||||
public:
|
||||
DumpTestSuite()
|
||||
DumpTestSuite() : wb(xlnt::optimization::write)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
//_COL_CONVERSION_CACHE = dict((get_column_letter(i), i) for i in range(1, 18279));
|
||||
|
||||
void test_dump_sheet_title()
|
||||
{
|
||||
xlnt::workbook wb(xlnt::optimization::write);
|
||||
auto ws = wb.create_sheet("Test1");
|
||||
wb.save(temp_file.GetFilename());
|
||||
xlnt::workbook wb2;
|
||||
|
@ -31,76 +28,99 @@ public:
|
|||
void test_dump_sheet()
|
||||
{
|
||||
auto test_filename = temp_file.GetFilename();
|
||||
|
||||
xlnt::workbook wb(xlnt::optimization::write);
|
||||
auto ws = wb.create_sheet();
|
||||
|
||||
std::vector<std::string> letters;
|
||||
|
||||
for(int i = 0; i < 20; i++)
|
||||
{
|
||||
letters.push_back(xlnt::cell_reference::column_string_from_index(i + 1));
|
||||
}
|
||||
|
||||
std::vector<std::vector<std::string>> expected_rows;
|
||||
|
||||
for(int row = 0; row < 20; row++)
|
||||
{
|
||||
expected_rows.push_back(std::vector<std::string>());
|
||||
std::vector<std::string> current_row;
|
||||
for(auto letter : letters)
|
||||
{
|
||||
expected_rows.back().push_back(letter + std::to_string(row + 1));
|
||||
current_row.push_back(letter + std::to_string(row + 1));
|
||||
}
|
||||
ws.append(current_row);
|
||||
}
|
||||
|
||||
for(int row = 0; row < 20; row++)
|
||||
{
|
||||
expected_rows.push_back(std::vector<std::string>());
|
||||
std::vector<int> current_row;
|
||||
for(auto letter : letters)
|
||||
{
|
||||
expected_rows.back().push_back(letter + std::to_string(row + 1));
|
||||
current_row.push_back(row + 1);
|
||||
}
|
||||
ws.append(current_row);
|
||||
}
|
||||
|
||||
for(int row = 0; row < 10; row++)
|
||||
{
|
||||
expected_rows.push_back(std::vector<std::string>());
|
||||
for(auto letter : letters)
|
||||
std::vector<xlnt::date> current_row;
|
||||
for(std::size_t x = 0; x < letters.size(); x++)
|
||||
{
|
||||
expected_rows.back().push_back(letter + std::to_string(row + 1));
|
||||
current_row.push_back(xlnt::date(2010, (x % 12) + 1, row + 1));
|
||||
}
|
||||
ws.append(current_row);
|
||||
}
|
||||
|
||||
for(auto row : expected_rows)
|
||||
for(int row = 0; row < 20; row++)
|
||||
{
|
||||
ws.append(row);
|
||||
std::vector<std::string> current_row;
|
||||
for(auto letter : letters)
|
||||
{
|
||||
current_row.push_back("=" + letter + std::to_string(row + 1));
|
||||
}
|
||||
ws.append(current_row);
|
||||
}
|
||||
|
||||
wb.save(test_filename);
|
||||
|
||||
//xlnt::workbook wb2;
|
||||
//wb2.load(test_filename);
|
||||
//ws = wb2[0];
|
||||
xlnt::workbook wb2;
|
||||
wb2.load(test_filename);
|
||||
ws = wb2[0];
|
||||
|
||||
auto expected_row = expected_rows.begin();
|
||||
for(auto row : ws.rows())
|
||||
{
|
||||
auto expected_cell = expected_row->begin();
|
||||
for(auto cell : row)
|
||||
{
|
||||
TS_ASSERT_EQUALS(cell, *expected_cell);
|
||||
expected_cell++;
|
||||
auto row = cell.get_row();
|
||||
|
||||
if(row <= 20)
|
||||
{
|
||||
std::string expected = cell.get_reference().to_string();
|
||||
TS_ASSERT_EQUALS(cell.get_data_type(), xlnt::cell::type::string);
|
||||
TS_ASSERT_EQUALS(cell, expected);
|
||||
}
|
||||
else if(row <= 40)
|
||||
{
|
||||
TS_ASSERT_EQUALS(cell.get_data_type(), xlnt::cell::type::numeric);
|
||||
TS_ASSERT_EQUALS(cell, (int)row);
|
||||
}
|
||||
else if(row <= 50)
|
||||
{
|
||||
xlnt::date expected(2010, (cell.get_reference().get_column_index() % 12) + 1, row + 1);
|
||||
TS_ASSERT_EQUALS(cell.get_data_type(), xlnt::cell::type::numeric);
|
||||
TS_ASSERT(cell.is_date());
|
||||
TS_ASSERT_EQUALS(cell, expected);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::string expected = "=" + cell.get_reference().to_string();
|
||||
TS_ASSERT_EQUALS(cell.get_data_type(), xlnt::cell::type::formula);
|
||||
TS_ASSERT_EQUALS(cell, expected);
|
||||
}
|
||||
}
|
||||
expected_row++;
|
||||
}
|
||||
}
|
||||
|
||||
void test_table_builder()
|
||||
{
|
||||
static const std::vector<std::pair<std::string, int>> result = {{"a", 0}, {"b", 1}, {"c", 2}, {"d", 3}};
|
||||
xlnt::string_table_builder sb;
|
||||
|
||||
std::vector<std::pair<std::string, int>> result = {{"a", 0}, {"b", 1}, {"c", 2}, {"d", 3}};
|
||||
|
||||
for(auto pair : result)
|
||||
{
|
||||
for(int i = 0; i < 5; i++)
|
||||
|
@ -117,25 +137,10 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
void test_open_too_many_files()
|
||||
{
|
||||
auto test_filename = temp_file.GetFilename();
|
||||
|
||||
xlnt::workbook wb(xlnt::optimization::write);
|
||||
|
||||
for(int i = 0; i < 2; i++) // over 200 worksheets should raise an OSError("too many open files")
|
||||
{
|
||||
wb.create_sheet();
|
||||
wb.save(test_filename);
|
||||
std::remove(test_filename.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
void test_dump_twice()
|
||||
{
|
||||
auto test_filename = temp_file.GetFilename();
|
||||
|
||||
xlnt::workbook wb(xlnt::optimization::write);
|
||||
auto ws = wb.create_sheet();
|
||||
|
||||
std::vector<std::string> to_append = {"hello"};
|
||||
|
@ -143,25 +148,24 @@ public:
|
|||
|
||||
wb.save(test_filename);
|
||||
std::remove(test_filename.c_str());
|
||||
wb.save(test_filename);
|
||||
|
||||
TS_ASSERT_THROWS(wb.save(test_filename), xlnt::workbook_already_saved);
|
||||
}
|
||||
|
||||
void test_append_after_save()
|
||||
{
|
||||
xlnt::workbook wb(xlnt::optimization::write);
|
||||
auto ws = wb.create_sheet();
|
||||
|
||||
std::vector<std::string> to_append = {"hello"};
|
||||
ws.append(to_append);
|
||||
|
||||
{
|
||||
TemporaryFile temp2;
|
||||
wb.save(temp2.GetFilename());
|
||||
}
|
||||
wb.save(temp_file.GetFilename());
|
||||
std::remove(temp_file.GetFilename().c_str());
|
||||
|
||||
ws.append(to_append);
|
||||
TS_ASSERT_THROWS(ws.append(to_append), xlnt::workbook_already_saved);
|
||||
}
|
||||
|
||||
private:
|
||||
xlnt::workbook wb;
|
||||
TemporaryFile temp_file;
|
||||
};
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
#include <Shlwapi.h>
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
#include <linux/limits.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
#endif
|
||||
|
||||
|
|
|
@ -118,7 +118,7 @@ public:
|
|||
{
|
||||
xlnt::worksheet ws(wb);
|
||||
wb.create_named_range("test_range_single", ws, "B12");
|
||||
TS_ASSERT_THROWS(ws.get_cell("test_range_single"), xlnt::bad_cell_coordinates);
|
||||
TS_ASSERT_THROWS(ws.get_cell("test_range_single"), xlnt::cell_coordinates_exception);
|
||||
auto c_range_name = ws.get_named_range("test_range_single");
|
||||
auto c_range_coord = ws.get_range("B12");
|
||||
auto c_cell = ws.get_cell("B12");
|
||||
|
@ -156,14 +156,14 @@ public:
|
|||
|
||||
ws.get_cell("A1").set_hyperlink("http:test.com");
|
||||
TS_ASSERT_EQUALS(ws.get_relationships().size(), 1);
|
||||
TS_ASSERT_EQUALS("rId1", ws.get_cell("A1").get_hyperlink_rel_id());
|
||||
TS_ASSERT_EQUALS("rId1", ws.get_cell("A1").get_hyperlink());
|
||||
TS_ASSERT_EQUALS("rId1", ws.get_relationships()[0].get_id());
|
||||
TS_ASSERT_EQUALS("http:test.com", ws.get_relationships()[0].get_target_uri());
|
||||
TS_ASSERT_EQUALS(xlnt::target_mode::external, ws.get_relationships()[0].get_target_mode());
|
||||
|
||||
ws.get_cell("A2").set_hyperlink("http:test2.com");
|
||||
TS_ASSERT_EQUALS(ws.get_relationships().size(), 2);
|
||||
TS_ASSERT_EQUALS("rId2", ws.get_cell("A2").get_hyperlink_rel_id());
|
||||
TS_ASSERT_EQUALS("rId2", ws.get_cell("A2").get_hyperlink());
|
||||
TS_ASSERT_EQUALS("rId2", ws.get_relationships()[1].get_id());
|
||||
TS_ASSERT_EQUALS("http:test2.com", ws.get_relationships()[1].get_target_uri());
|
||||
TS_ASSERT_EQUALS(xlnt::target_mode::external, ws.get_relationships()[1].get_target_mode());
|
||||
|
|
|
@ -154,8 +154,8 @@ public:
|
|||
{
|
||||
xlnt::workbook wb;
|
||||
auto ws = wb.create_sheet();
|
||||
ws.get_cell("A1").set_hyperlink("http:test.com");
|
||||
TS_ASSERT_EQUALS("http:test.com", ws.get_cell("A1"));
|
||||
ws.get_cell("A1").set_hyperlink("http://test.com");
|
||||
TS_ASSERT_EQUALS("http://test.com", ws.get_cell("A1"));
|
||||
ws.get_cell("A1") = "test";
|
||||
TS_ASSERT_EQUALS("test", ws.get_cell("A1"));
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ int main( int argc, char *argv[] ) {
|
|||
return status;
|
||||
}
|
||||
bool suite_CellTestSuite_init = false;
|
||||
#include "/Users/thomas/Development/xlnt/tests/CellTestSuite.h"
|
||||
#include "/home/thomas/Development/xlnt/tests/CellTestSuite.h"
|
||||
|
||||
static CellTestSuite suite_CellTestSuite;
|
||||
|
||||
|
@ -72,119 +72,119 @@ public:
|
|||
|
||||
static class TestDescription_suite_CellTestSuite_test_column_letter_boundries : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_column_letter_boundries() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 81, "test_column_letter_boundries" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_column_letter_boundries() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 82, "test_column_letter_boundries" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_column_letter_boundries(); }
|
||||
} testDescription_suite_CellTestSuite_test_column_letter_boundries;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_column_letter : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_column_letter() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 88, "test_column_letter" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_column_letter() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 91, "test_column_letter" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_column_letter(); }
|
||||
} testDescription_suite_CellTestSuite_test_column_letter;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_initial_value : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_initial_value() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 98, "test_initial_value" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_initial_value() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 101, "test_initial_value" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_initial_value(); }
|
||||
} testDescription_suite_CellTestSuite_test_initial_value;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_null : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_null() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 107, "test_null" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_null() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 109, "test_null" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_null(); }
|
||||
} testDescription_suite_CellTestSuite_test_null;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_numeric : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_numeric() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 116, "test_numeric" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_numeric() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 117, "test_numeric" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_numeric(); }
|
||||
} testDescription_suite_CellTestSuite_test_numeric;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_string : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_string() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 148, "test_string" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_string() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 159, "test_string" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_string(); }
|
||||
} testDescription_suite_CellTestSuite_test_string;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_single_dot : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_single_dot() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 158, "test_single_dot" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_single_dot() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 168, "test_single_dot" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_single_dot(); }
|
||||
} testDescription_suite_CellTestSuite_test_single_dot;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_formula : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_formula() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 167, "test_formula" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_formula() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 176, "test_formula" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_formula(); }
|
||||
} testDescription_suite_CellTestSuite_test_formula;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_boolean : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_boolean() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 176, "test_boolean" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_boolean() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 184, "test_boolean" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_boolean(); }
|
||||
} testDescription_suite_CellTestSuite_test_boolean;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_leading_zero : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_leading_zero() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 187, "test_leading_zero" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_leading_zero() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 194, "test_leading_zero" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_leading_zero(); }
|
||||
} testDescription_suite_CellTestSuite_test_leading_zero;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_error_codes : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_error_codes() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 196, "test_error_codes" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_error_codes() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 202, "test_error_codes" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_error_codes(); }
|
||||
} testDescription_suite_CellTestSuite_test_error_codes;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_data_type_check : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_data_type_check() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 210, "test_data_type_check" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_data_type_check() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 215, "test_data_type_check" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_data_type_check(); }
|
||||
} testDescription_suite_CellTestSuite_test_data_type_check;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_set_bad_type : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_set_bad_type() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 228, "test_set_bad_type" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_set_bad_type() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 232, "test_set_bad_type" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_set_bad_type(); }
|
||||
} testDescription_suite_CellTestSuite_test_set_bad_type;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_time : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_time() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 238, "test_time" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_time() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 250, "test_time" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_time(); }
|
||||
} testDescription_suite_CellTestSuite_test_time;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_date_format_on_non_date : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_date_format_on_non_date() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 260, "test_date_format_on_non_date" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_date_format_on_non_date() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 264, "test_date_format_on_non_date" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_date_format_on_non_date(); }
|
||||
} testDescription_suite_CellTestSuite_test_date_format_on_non_date;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_set_get_date : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_set_get_date() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 273, "test_set_get_date" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_set_get_date() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 274, "test_set_get_date" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_set_get_date(); }
|
||||
} testDescription_suite_CellTestSuite_test_set_get_date;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_repr : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_repr() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 291, "test_repr" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_repr() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 285, "test_repr" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_repr(); }
|
||||
} testDescription_suite_CellTestSuite_test_repr;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_is_date : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_is_date() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 300, "test_is_date" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_is_date() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 293, "test_is_date" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_is_date(); }
|
||||
} testDescription_suite_CellTestSuite_test_is_date;
|
||||
|
||||
static class TestDescription_suite_CellTestSuite_test_is_not_date_color_format : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_CellTestSuite_test_is_not_date_color_format() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 317, "test_is_not_date_color_format" ) {}
|
||||
TestDescription_suite_CellTestSuite_test_is_not_date_color_format() : CxxTest::RealTestDescription( Tests_CellTestSuite, suiteDescription_CellTestSuite, 307, "test_is_not_date_color_format" ) {}
|
||||
void runTest() { suite_CellTestSuite.test_is_not_date_color_format(); }
|
||||
} testDescription_suite_CellTestSuite_test_is_not_date_color_format;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/ChartTestSuite.h"
|
||||
#include "/home/thomas/Development/xlnt/tests/ChartTestSuite.h"
|
||||
|
||||
static ChartTestSuite suite_ChartTestSuite;
|
||||
|
||||
|
@ -275,7 +275,7 @@ public:
|
|||
void runTest() { suite_ChartTestSuite.test_write_chart_scatter(); }
|
||||
} testDescription_suite_ChartTestSuite_test_write_chart_scatter;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/DumpTestSuite.h"
|
||||
#include "/home/thomas/Development/xlnt/tests/DumpTestSuite.h"
|
||||
|
||||
static DumpTestSuite suite_DumpTestSuite;
|
||||
|
||||
|
@ -284,41 +284,35 @@ CxxTest::StaticSuiteDescription suiteDescription_DumpTestSuite( "../../tests/Dum
|
|||
|
||||
static class TestDescription_suite_DumpTestSuite_test_dump_sheet_title : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_DumpTestSuite_test_dump_sheet_title() : CxxTest::RealTestDescription( Tests_DumpTestSuite, suiteDescription_DumpTestSuite, 19, "test_dump_sheet_title" ) {}
|
||||
TestDescription_suite_DumpTestSuite_test_dump_sheet_title() : CxxTest::RealTestDescription( Tests_DumpTestSuite, suiteDescription_DumpTestSuite, 17, "test_dump_sheet_title" ) {}
|
||||
void runTest() { suite_DumpTestSuite.test_dump_sheet_title(); }
|
||||
} testDescription_suite_DumpTestSuite_test_dump_sheet_title;
|
||||
|
||||
static class TestDescription_suite_DumpTestSuite_test_dump_sheet : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_DumpTestSuite_test_dump_sheet() : CxxTest::RealTestDescription( Tests_DumpTestSuite, suiteDescription_DumpTestSuite, 31, "test_dump_sheet" ) {}
|
||||
TestDescription_suite_DumpTestSuite_test_dump_sheet() : CxxTest::RealTestDescription( Tests_DumpTestSuite, suiteDescription_DumpTestSuite, 28, "test_dump_sheet" ) {}
|
||||
void runTest() { suite_DumpTestSuite.test_dump_sheet(); }
|
||||
} testDescription_suite_DumpTestSuite_test_dump_sheet;
|
||||
|
||||
static class TestDescription_suite_DumpTestSuite_test_table_builder : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_DumpTestSuite_test_table_builder() : CxxTest::RealTestDescription( Tests_DumpTestSuite, suiteDescription_DumpTestSuite, 98, "test_table_builder" ) {}
|
||||
TestDescription_suite_DumpTestSuite_test_table_builder() : CxxTest::RealTestDescription( Tests_DumpTestSuite, suiteDescription_DumpTestSuite, 119, "test_table_builder" ) {}
|
||||
void runTest() { suite_DumpTestSuite.test_table_builder(); }
|
||||
} testDescription_suite_DumpTestSuite_test_table_builder;
|
||||
|
||||
static class TestDescription_suite_DumpTestSuite_test_open_too_many_files : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_DumpTestSuite_test_open_too_many_files() : CxxTest::RealTestDescription( Tests_DumpTestSuite, suiteDescription_DumpTestSuite, 120, "test_open_too_many_files" ) {}
|
||||
void runTest() { suite_DumpTestSuite.test_open_too_many_files(); }
|
||||
} testDescription_suite_DumpTestSuite_test_open_too_many_files;
|
||||
|
||||
static class TestDescription_suite_DumpTestSuite_test_dump_twice : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_DumpTestSuite_test_dump_twice() : CxxTest::RealTestDescription( Tests_DumpTestSuite, suiteDescription_DumpTestSuite, 134, "test_dump_twice" ) {}
|
||||
TestDescription_suite_DumpTestSuite_test_dump_twice() : CxxTest::RealTestDescription( Tests_DumpTestSuite, suiteDescription_DumpTestSuite, 140, "test_dump_twice" ) {}
|
||||
void runTest() { suite_DumpTestSuite.test_dump_twice(); }
|
||||
} testDescription_suite_DumpTestSuite_test_dump_twice;
|
||||
|
||||
static class TestDescription_suite_DumpTestSuite_test_append_after_save : public CxxTest::RealTestDescription {
|
||||
public:
|
||||
TestDescription_suite_DumpTestSuite_test_append_after_save() : CxxTest::RealTestDescription( Tests_DumpTestSuite, suiteDescription_DumpTestSuite, 149, "test_append_after_save" ) {}
|
||||
TestDescription_suite_DumpTestSuite_test_append_after_save() : CxxTest::RealTestDescription( Tests_DumpTestSuite, suiteDescription_DumpTestSuite, 155, "test_append_after_save" ) {}
|
||||
void runTest() { suite_DumpTestSuite.test_append_after_save(); }
|
||||
} testDescription_suite_DumpTestSuite_test_append_after_save;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/NamedRangeTestSuite.h"
|
||||
#include "/home/thomas/Development/xlnt/tests/NamedRangeTestSuite.h"
|
||||
|
||||
static NamedRangeTestSuite suite_NamedRangeTestSuite;
|
||||
|
||||
|
@ -409,7 +403,7 @@ public:
|
|||
void runTest() { suite_NamedRangeTestSuite.test_can_be_saved(); }
|
||||
} testDescription_suite_NamedRangeTestSuite_test_can_be_saved;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/NumberFormatTestSuite.h"
|
||||
#include "/home/thomas/Development/xlnt/tests/NumberFormatTestSuite.h"
|
||||
|
||||
static NumberFormatTestSuite suite_NumberFormatTestSuite;
|
||||
|
||||
|
@ -512,7 +506,7 @@ public:
|
|||
void runTest() { suite_NumberFormatTestSuite.test_mac_date(); }
|
||||
} testDescription_suite_NumberFormatTestSuite_test_mac_date;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/PropsTestSuite.h"
|
||||
#include "/home/thomas/Development/xlnt/tests/PropsTestSuite.h"
|
||||
|
||||
static PropsTestSuite suite_PropsTestSuite;
|
||||
|
||||
|
@ -555,7 +549,7 @@ public:
|
|||
void runTest() { suite_PropsTestSuite.test_write_properties_app(); }
|
||||
} testDescription_suite_PropsTestSuite_test_write_properties_app;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/ReadTestSuite.h"
|
||||
#include "/home/thomas/Development/xlnt/tests/ReadTestSuite.h"
|
||||
|
||||
static ReadTestSuite suite_ReadTestSuite;
|
||||
|
||||
|
@ -688,7 +682,7 @@ public:
|
|||
void runTest() { suite_ReadTestSuite.test_read_date_value(); }
|
||||
} testDescription_suite_ReadTestSuite_test_read_date_value;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/StringsTestSuite.h"
|
||||
#include "/home/thomas/Development/xlnt/tests/StringsTestSuite.h"
|
||||
|
||||
static StringsTestSuite suite_StringsTestSuite;
|
||||
|
||||
|
@ -719,7 +713,7 @@ public:
|
|||
void runTest() { suite_StringsTestSuite.test_formatted_string_table(); }
|
||||
} testDescription_suite_StringsTestSuite_test_formatted_string_table;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/StyleTestSuite.h"
|
||||
#include "/home/thomas/Development/xlnt/tests/StyleTestSuite.h"
|
||||
|
||||
static StyleTestSuite suite_StyleTestSuite;
|
||||
|
||||
|
@ -816,7 +810,7 @@ public:
|
|||
void runTest() { suite_StyleTestSuite.test_read_cell_style(); }
|
||||
} testDescription_suite_StyleTestSuite_test_read_cell_style;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/ThemeTestSuite.h"
|
||||
#include "/home/thomas/Development/xlnt/tests/ThemeTestSuite.h"
|
||||
|
||||
static ThemeTestSuite suite_ThemeTestSuite;
|
||||
|
||||
|
@ -829,7 +823,7 @@ public:
|
|||
void runTest() { suite_ThemeTestSuite.test_write_theme(); }
|
||||
} testDescription_suite_ThemeTestSuite_test_write_theme;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/WorkbookTestSuite.h"
|
||||
#include "/home/thomas/Development/xlnt/tests/WorkbookTestSuite.h"
|
||||
|
||||
static WorkbookTestSuite suite_WorkbookTestSuite;
|
||||
|
||||
|
@ -956,7 +950,7 @@ public:
|
|||
void runTest() { suite_WorkbookTestSuite.test_write_regular_float(); }
|
||||
} testDescription_suite_WorkbookTestSuite_test_write_regular_float;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/WorksheetTestSuite.h"
|
||||
#include "/home/thomas/Development/xlnt/tests/WorksheetTestSuite.h"
|
||||
|
||||
static WorksheetTestSuite suite_WorksheetTestSuite;
|
||||
|
||||
|
@ -1125,7 +1119,7 @@ public:
|
|||
void runTest() { suite_WorksheetTestSuite.test_printer_settings(); }
|
||||
} testDescription_suite_WorksheetTestSuite_test_printer_settings;
|
||||
|
||||
#include "/Users/thomas/Development/xlnt/tests/WriteTestSuite.h"
|
||||
#include "/home/thomas/Development/xlnt/tests/WriteTestSuite.h"
|
||||
|
||||
static WriteTestSuite suite_WriteTestSuite;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user