diff --git a/include/xlnt/worksheet/range.hpp b/include/xlnt/worksheet/range.hpp index 0abebbcf..02b88a13 100644 --- a/include/xlnt/worksheet/range.hpp +++ b/include/xlnt/worksheet/range.hpp @@ -290,11 +290,11 @@ public: /// bool operator!=(const range &comparand) const; -private: + private: /// /// The worksheet this range is within /// - worksheet ws_; + class worksheet ws_; /// /// The reference of this range diff --git a/source/cell/cell.cpp b/source/cell/cell.cpp index 4426a5dc..96c1a021 100644 --- a/source/cell/cell.cpp +++ b/source/cell/cell.cpp @@ -434,6 +434,18 @@ void cell::hyperlink(xlnt::cell target) value(cell_address); } +void cell::hyperlink(xlnt::range target) +{ + // TODO: should this computed value be a method on a cell? + const auto range_address = target.worksheet().title() + "!" + target.reference().to_string(); + + d_->hyperlink_ = detail::hyperlink_impl(); + d_->hyperlink_.get().relationship = xlnt::relationship("", relationship_type::hyperlink, + uri(""), uri(range_address), target_mode::internal); + d_->hyperlink_.get().display = range_address; + value(range_address); +} + void cell::formula(const std::string &formula) { if (formula.empty()) @@ -472,6 +484,15 @@ void cell::clear_formula() } } +std::string cell::error() const +{ + if (d_->type_ != type::error) + { + throw xlnt::exception("called error() when cell type is not error"); + } + return value(); +} + void cell::error(const std::string &error) { if (error.length() == 0 || error[0] != '#') @@ -743,6 +764,11 @@ calendar cell::base_date() const return workbook().base_date(); } +bool operator==(std::nullptr_t, const cell &cell) +{ + return cell.data_type() == cell::type::empty; +} + XLNT_API std::ostream &operator<<(std::ostream &stream, const xlnt::cell &cell) { return stream << cell.to_string(); diff --git a/source/cell/rich_text.cpp b/source/cell/rich_text.cpp index ad5cccbd..5c3ff4fb 100644 --- a/source/cell/rich_text.cpp +++ b/source/cell/rich_text.cpp @@ -65,6 +65,11 @@ std::vector rich_text::runs() const return runs_; } +void rich_text::runs(const std::vector &new_runs) +{ + runs_ = new_runs; +} + void rich_text::add_run(const rich_text_run &t) { runs_.push_back(t); diff --git a/source/worksheet/range.cpp b/source/worksheet/range.cpp index fa8e8eb2..1226cc0b 100644 --- a/source/worksheet/range.cpp +++ b/source/worksheet/range.cpp @@ -31,7 +31,7 @@ namespace xlnt { -range::range(worksheet ws, const range_reference &reference, major_order order, bool skip_null) +range::range(class worksheet ws, const range_reference &reference, major_order order, bool skip_null) : ws_(ws), ref_(reference), order_(order),