All unimplemented functions under cell/

This commit is contained in:
Crzyrndm 2018-07-02 10:29:58 +12:00
parent e0d62b0835
commit 947037b9d2
4 changed files with 44 additions and 3 deletions

View File

@ -117,6 +117,11 @@ public:
/// </summary>
const class cell cell(const cell_reference &ref) const;
/// <summary>
/// The worksheet this range targets
/// </summary>
const worksheet &worksheet() const;
/// <summary>
/// Returns the reference defining the bounds of this range.
/// </summary>
@ -285,11 +290,11 @@ public:
/// </summary>
bool operator!=(const range &comparand) const;
private:
private:
/// <summary>
/// The worksheet this range is within
/// </summary>
worksheet ws_;
class worksheet ws_;
/// <summary>
/// The reference of this range

View File

@ -429,6 +429,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())
@ -467,6 +479,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<std::string>();
}
void cell::error(const std::string &error)
{
if (error.length() == 0 || error[0] != '#')
@ -738,6 +759,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();

View File

@ -65,6 +65,11 @@ std::vector<rich_text_run> rich_text::runs() const
return runs_;
}
void rich_text::runs(const std::vector<rich_text_run> &new_runs)
{
runs_ = new_runs;
}
void rich_text::add_run(const rich_text_run &t)
{
runs_.push_back(t);

View File

@ -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),
@ -71,6 +71,11 @@ cell_vector range::operator[](std::size_t index)
return vector(index);
}
const worksheet &range::worksheet() const
{
return ws_;
}
range_reference range::reference() const
{
return ref_;