OpenXLSX 1.9.1
Loading...
Searching...
No Matches
XLCellValue.hpp
Go to the documentation of this file.
1#ifndef OPENXLSX_XLCELLVALUE_HPP
2#define OPENXLSX_XLCELLVALUE_HPP
3
4#ifdef _MSC_VER // conditionally enable MSVC specific pragmas to avoid other compilers warning about unknown pragmas
5# pragma warning(push)
6# pragma warning(disable : 4251)
7# pragma warning(disable : 4275)
8#endif // _MSC_VER
9
10// ===== External Includes ===== //
11#include <cmath>
12#include <cstdint>
13#include <fast_float/fast_float.h>
14#include <fmt/base.h>
15#include <fmt/format.h>
16#include <iostream>
17#include <string>
18#include <variant>
19
20// ===== OpenXLSX Includes ===== //
21#include "OpenXLSX-Exports.hpp"
22#include "XLDateTime.hpp"
23#include "XLException.hpp"
24#include "XLRichText.hpp"
25#include "XLXmlParser.hpp"
26
27typedef std::variant<std::string, int64_t, double, bool, OpenXLSX::XLRichText> XLCellValueType;
28
29namespace OpenXLSX
30{
31 class XLCellValueProxy;
32 class XLCell;
33
38
39 //---------- Private Struct to enable XLValueType conversion to double ---------- //
41 {
42 std::string packageName = "VisitXLCellValueTypeToDouble";
43 double operator()(int64_t v) const { return static_cast<double>(v); }
44 double operator()(double v) const { return v; }
45 double operator()(bool v) const { return v; }
46 // double operator()( struct timestamp v ) { /* to be implemented if this type ever gets supported */ }
47 double operator()([[maybe_unused]] const OpenXLSX::XLRichText& v) const
48 {
49 throw XLValueTypeError("RichText is not convertible to double.");
50 return 0.0;
51 }
52 double operator()(std::string v) const
53 {
54 throw XLValueTypeError(
55 "string is not convertible to double."); // disable if implicit conversion of string to double shall be allowed
56 double val;
57 auto [ptr, ec] = fast_float::from_chars(v.data(), v.data() + v.size(), val);
58 if (ec != std::errc()) throw XLValueTypeError("string is not convertible to double.");
59 return val;
60 }
61 };
62
63 //---------- Private Struct to enable XLValueType conversion to std::string ---------- //
65 {
66 std::string packageName = "VisitXLCellValueTypeToString";
67 std::string operator()(int64_t v) const { return fmt::format("{}", v); }
68 std::string operator()(double v) const { return fmt::format("{}", v); }
69 std::string operator()(bool v) const { return v ? "true" : "false"; }
70 // std::string operator()( struct timestamp v ) { return timestampString( v.seconds, v.microseconds, WITH_MS ); }
71 std::string operator()(const XLRichText& v) const { return v.plainText(); }
72 std::string operator()(std::string v) const { return v; }
73 };
74
78 class OPENXLSX_EXPORT XLCellValue
79 {
80 friend class XLCellValueProxy; // to allow access to m_value
81
82 // Comparison operators between XLCellValue objects
83 friend bool operator==(const XLCellValue& lhs, const XLCellValue& rhs);
84 friend bool operator!=(const XLCellValue& lhs, const XLCellValue& rhs);
85 friend bool operator<(const XLCellValue& lhs, const XLCellValue& rhs);
86 friend bool operator>(const XLCellValue& lhs, const XLCellValue& rhs);
87 friend bool operator<=(const XLCellValue& lhs, const XLCellValue& rhs);
88 friend bool operator>=(const XLCellValue& lhs, const XLCellValue& rhs);
89 friend std::ostream& operator<<(std::ostream& os, const XLCellValue& value);
90 friend std::hash<OpenXLSX::XLCellValue>;
91
92#define OPENXLSX_XLCELLVALUE_FRIEND_STRING_OP(OP, FUNCTOR) \
93 friend bool operator OP(const XLCellValue& lhs, std::string_view rhs) \
94 { \
95 if (std::holds_alternative<std::string>(lhs.m_value)) \
96 return FUNCTOR<>{}(std::string_view(std::get<std::string>(lhs.m_value)), rhs); \
97 return false; \
98 } \
99 friend bool operator OP(std::string_view lhs, const XLCellValue& rhs) \
100 { \
101 if (std::holds_alternative<std::string>(rhs.m_value)) \
102 return FUNCTOR<>{}(lhs, std::string_view(std::get<std::string>(rhs.m_value))); \
103 return false; \
104 } \
105 friend bool operator OP(const XLCellValue& lhs, const char* rhs) { return lhs OP std::string_view(rhs); } \
106 friend bool operator OP(const char* lhs, const XLCellValue& rhs) { return std::string_view(lhs) OP rhs; } \
107 friend bool operator OP(const XLCellValue& lhs, const std::string& rhs) { return lhs OP std::string_view(rhs); } \
108 friend bool operator OP(const std::string& lhs, const XLCellValue& rhs) { return std::string_view(lhs) OP rhs; }
109
111 OPENXLSX_XLCELLVALUE_FRIEND_STRING_OP(!=, std::not_equal_to)
114 OPENXLSX_XLCELLVALUE_FRIEND_STRING_OP(<=, std::less_equal)
115 OPENXLSX_XLCELLVALUE_FRIEND_STRING_OP(>=, std::greater_equal)
116
117#undef OPENXLSX_XLCELLVALUE_FRIEND_STRING_OP
118
119 public:
124
131 template<typename T,
132 typename = std::enable_if_t<
133 std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> ||
134 std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>, const char*> ||
135 std::is_same_v<std::decay_t<T>, char*> or std::is_same_v<T, OpenXLSX::XLRichText> or std::is_same_v<T, XLDateTime>>>
136 XLCellValue(const T& value) // NOLINT
137 {
138 // ===== If the argument is a bool, set the m_type attribute to Boolean.
139 if constexpr (std::is_integral_v<T> and std::is_same_v<T, bool>) {
140 m_type = XLValueType::Boolean;
141 m_value = value;
142 }
143
144 // ===== If the argument is an integral type, set the m_type attribute to Integer.
145 else if constexpr (std::is_integral_v<T> and !std::is_same_v<T, bool>) {
146 m_type = XLValueType::Integer;
147 m_value = static_cast<int64_t>(value);
148 }
149
150 // ===== If the argument is a string type (i.e. is constructable from *char),
151 // ===== set the m_type attribute to String.
152 else if constexpr (std::is_same_v<std::decay_t<T>, std::string> or std::is_same_v<std::decay_t<T>, std::string_view> ||
153 std::is_same_v<std::decay_t<T>, const char*> ||
154 (std::is_same_v<std::decay_t<T>, char*> and !std::is_same_v<T, bool>))
155 {
156 m_type = XLValueType::String;
157 m_value = std::string(value);
158 }
159
160 // ===== If the argument is an XLDateTime, set the value to the date/time serial number.
161 else if constexpr (std::is_same_v<T, XLDateTime>) {
162 m_type = XLValueType::Float;
163 m_value = value.serial();
164 }
165
166 // ===== If the argument is an XLRichText, set the m_type attribute to RichText.
167 else if constexpr (std::is_same_v<T, XLRichText>) {
168 m_type = XLValueType::RichText;
169 m_value = value;
170 }
171
172 // ===== If the argument is a floating point type, set the m_type attribute to Float.
173 // ===== If not, a static_assert will result in compilation error.
174 else {
175 static_assert(std::is_floating_point_v<T>, "Invalid argument for constructing XLCellValue object");
176 if (std::isfinite(value)) {
177 m_type = XLValueType::Float;
178 m_value = static_cast<double>(value);
179 }
180 else {
181 m_type = XLValueType::Error;
182 m_value = std::string("#NUM!");
183 }
184 }
185 }
186
192
197 XLCellValue(XLCellValue&& other) noexcept;
198
203
210
217
224 template<typename T,
225 typename = std::enable_if_t<
226 std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> ||
227 std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>, const char*> ||
228 std::is_same_v<std::decay_t<T>, char*> or std::is_same_v<T, OpenXLSX::XLRichText> or std::is_same_v<T, XLDateTime>>>
230 {
231 // ===== Implemented using copy-and-swap.
232 XLCellValue temp(value);
233 std::swap(*this, temp);
234 return *this;
235 }
236
242 template<
243 typename T,
244 typename = std::enable_if_t<std::is_same_v<T, XLCellValue> or std::is_integral_v<T> or std::is_floating_point_v<T> ||
245 std::is_same_v<std::decay_t<T>, std::string> or std::is_same_v<std::decay_t<T>, std::string_view> ||
246 std::is_same_v<std::decay_t<T>, const char*> or std::is_same_v<std::decay_t<T>, char*> ||
247 std::is_same_v<T, OpenXLSX::XLRichText> or std::is_same_v<T, XLDateTime>>>
248 void set(T numberValue)
249 {
250 // ===== Implemented using the assignment operator.
251 *this = numberValue;
252 }
253
260 template<typename T,
261 typename = std::enable_if_t<
262 std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> ||
263 std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>, const char*> ||
264 std::is_same_v<std::decay_t<T>, char*> or std::is_same_v<T, XLDateTime> or std::is_same_v<T, OpenXLSX::XLRichText>>>
265 T get() const
266 {
267 try {
268 return privateGet<T>();
269 }
270
271 catch (const std::bad_variant_access&) {
272 throw XLValueTypeError("XLCellValue object does not contain the requested type.");
273 }
274 }
275
276 private:
284 template<typename T,
285 typename = std::enable_if_t<
286 std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> ||
287 std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>, const char*> ||
288 std::is_same_v<std::decay_t<T>, char*> or std::is_same_v<T, OpenXLSX::XLRichText> or std::is_same_v<T, XLDateTime>>>
289 T privateGet() const
290 {
291 try {
292 if constexpr (std::is_integral_v<T> and std::is_same_v<T, bool>) return std::get<bool>(m_value);
293
294 if constexpr (std::is_integral_v<T> and !std::is_same_v<T, bool>) return static_cast<T>(std::get<int64_t>(m_value));
295
296 if constexpr (std::is_floating_point_v<T>) {
297 return static_cast<T>(getDouble()); // 2025-01-10: allow implicit conversion of int and bool to double (string
298 // conversion disabled for now)
299 // if (m_type == XLValueType::Error) return static_cast<T>(std::nan("1"));
300 // return static_cast<T>(std::get<double>(m_value));
301 }
302
303 if constexpr (std::is_same_v<std::decay_t<T>, std::string> or std::is_same_v<std::decay_t<T>, std::string_view> ||
304 std::is_same_v<std::decay_t<T>, const char*> ||
305 (std::is_same_v<std::decay_t<T>, char*> and !std::is_same_v<T, bool>))
306 return std::get<std::string>(m_value).c_str();
307
308 if constexpr (std::is_same_v<T, OpenXLSX::XLRichText>) return std::get<OpenXLSX::XLRichText>(m_value);
309
310 if constexpr (std::is_same_v<T, XLDateTime>)
311 return XLDateTime(getDouble()); // 2025-01-10: allow implicit conversion of int and bool to double (string conversion
312 // disabled for now)
313 }
314
315 catch (const std::bad_variant_access&) {
316 throw XLValueTypeError("XLCellValue object does not contain the requested type.");
317 }
318 }
319
320 public:
326 double getDouble() const
327 {
328 if (m_type == XLValueType::Error) return static_cast<double>(std::nan("1"));
329 try {
330 return std::visit(VisitXLCellValueTypeToDouble(), m_value);
331 }
332 catch (...) {
333 throw XLValueTypeError("XLCellValue object is not convertible to double.");
334 }
335 }
336
342 std::string getString() // pull request #158 is covered by this
343 {
344 try {
345 return std::visit(VisitXLCellValueTypeToString(), m_value);
346 }
347 catch (...) { // 2024-05-27: was catch( string s ) - must have been a typo, currently nothing throws a string here
348 throw XLValueTypeError("XLCellValue object is not convertible to string.");
349 }
350 }
351
356 const XLCellValueType& getVariant() const // pull request #127
357 { return m_value; }
358
365 template<typename T,
366 typename = std::enable_if_t<
367 std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> ||
368 std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>, const char*> ||
369 std::is_same_v<std::decay_t<T>, char*> or std::is_same_v<T, OpenXLSX::XLRichText> or std::is_same_v<T, XLDateTime>>>
370 operator T() const
371 { return this->get<T>(); }
372
377 XLCellValue& clear();
378
383 XLCellValue& setError(const std::string& error);
384
389 XLValueType type() const;
390
395 const char* typeAsString() const;
396
397 private:
398 XLCellValueType m_value{std::string("")};
399 XLValueType m_type{XLValueType::Empty};
400 };
401
407 class OPENXLSX_EXPORT XLCellValueProxy
408 {
409 friend class XLCell;
410 friend class XLCellValue;
411 friend class XLDocument; // for reindexing shared strings
412
413 public:
418
424 XLCellValueProxy& operator=(const XLCellValueProxy& other);
425
432 template<typename T,
433 typename = std::enable_if_t<
434 std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> ||
435 std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>, const char*> ||
436 std::is_same_v<std::decay_t<T>, char*> or std::is_same_v<T, XLCellValue> or std::is_same_v<T, XLDateTime> or
437 std::is_same_v<T, OpenXLSX::XLRichText>>>
439 { // NOLINT
440
441 if constexpr (std::is_integral_v<T> and std::is_same_v<T, bool>) // if bool
442 setBoolean(value);
443
444 else if constexpr (std::is_integral_v<T> and !std::is_same_v<T, bool>) // if integer
445 setInteger(value);
446
447 else if constexpr (std::is_floating_point_v<T>) // if floating point
448 setFloat(value);
449
450 else if constexpr (std::is_same_v<T, XLDateTime>)
451 setFloat(value.serial());
452
453 else if constexpr (std::is_same_v<T, OpenXLSX::XLRichText>)
454 setRichText(value);
455
456 else if constexpr (std::is_same_v<std::decay_t<T>, std::string> or std::is_same_v<std::decay_t<T>, std::string_view> ||
457 std::is_same_v<std::decay_t<T>, const char*> ||
458 (std::is_same_v<std::decay_t<T>, char*> and !std::is_same_v<T, bool> and !std::is_same_v<T, XLCellValue>))
459 {
460 setString(value);
461 }
462
463 if constexpr (std::is_same_v<T, XLCellValue>) {
464 switch (value.type()) {
465 case XLValueType::Boolean:
466 setBoolean(value.template get<bool>());
467 break;
468 case XLValueType::Integer:
469 setInteger(value.template get<int64_t>());
470 break;
471 case XLValueType::Float:
472 setFloat(value.template get<double>());
473 break;
474 case XLValueType::String:
475 setString(value.template privateGet<const char*>());
476 break;
477 case XLValueType::RichText:
478 setRichText(value.template get<OpenXLSX::XLRichText>());
479 break;
480 case XLValueType::Empty:
481 clear();
482 break;
483 default:
484 setError("#N/A");
485 break;
486 }
487 }
488
489 return *this;
490 }
491
497 template<typename T,
498 typename = std::enable_if_t<
499 std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> ||
500 std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>, const char*> ||
501 std::is_same_v<std::decay_t<T>, char*> or std::is_same_v<T, XLCellValue> or std::is_same_v<T, XLDateTime> or
502 std::is_same_v<T, OpenXLSX::XLRichText>>>
503 void set(const T& value)
504 { *this = value; }
505
510 template<typename T,
511 typename = std::enable_if_t<
512 std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> ||
513 std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>, const char*> ||
514 std::is_same_v<std::decay_t<T>, char*> or std::is_same_v<T, OpenXLSX::XLRichText> or std::is_same_v<T, XLDateTime>>>
515 T get() const
516 {
517 if constexpr (std::is_same_v<std::decay_t<T>, std::string_view> || std::is_same_v<std::decay_t<T>, const char*>) {
518 auto view = getStringView();
519 if constexpr (std::is_same_v<std::decay_t<T>, const char*>) return view.data();
520 else return view;
521 }
522 else if constexpr (std::is_same_v<std::decay_t<T>, std::string>) {
523 return std::string(getStringView());
524 }
525 else {
526 return getValue().get<T>();
527 }
528 }
529
534 XLCellValueProxy& clear();
535
540 XLCellValueProxy& setError(const std::string& error);
541
546 XLValueType type() const;
547
552 const char* typeAsString() const;
553
558 operator XLCellValue() const; // NOLINT
559
565 template<typename T,
566 typename = std::enable_if_t<
567 std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> ||
568 std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>, const char*> ||
569 std::is_same_v<std::decay_t<T>, char*> or std::is_same_v<T, OpenXLSX::XLRichText> or std::is_same_v<T, XLDateTime>>>
570 operator T() const
571 { return getValue().get<T>(); }
572
583 std::string_view getStringView() const;
584 std::string getString() const // pull request #158 is covered by this
585 {
586 try {
587 return std::visit(VisitXLCellValueTypeToString(), getValue().m_value);
588 }
589 catch (std::string s) {
590 throw XLValueTypeError("XLCellValue object is not convertible to string.");
591 }
592 }
593
594 private:
600 XLCellValueProxy(XLCell* cell, XMLNode* cellNode);
601
607
612 XLCellValueProxy(XLCellValueProxy&& other) noexcept;
613
619 XLCellValueProxy& operator=(XLCellValueProxy&& other) noexcept;
620
625 void setInteger(int64_t numberValue);
626
631 void setBoolean(bool numberValue);
632
637 void setFloat(double numberValue);
638
643 void setString(std::string_view stringValue);
644
649 void setRichText(const XLRichText& richTextValue);
650
655 XLCellValue getValue() const;
656
662 int32_t stringIndex() const;
663
669 bool setStringIndex(int32_t newIndex);
670 XLCell* m_cell;
671 XMLNode* m_cellNode;
672 };
673
674} // namespace OpenXLSX
675
676#include <functional>
677
678namespace OpenXLSX
679{
680 // Utility for cross-type comparison
681 template<typename Op>
682 struct XLCompareVisitor
683 {
684 template<typename T, typename U>
685 bool operator()(const T& lhs, const U& rhs) const
686 {
687 if constexpr (std::is_arithmetic_v<T> && std::is_arithmetic_v<U> && !std::is_same_v<T, bool> && !std::is_same_v<U, bool>) {
688 return Op{}(lhs, rhs);
689 }
690 else if constexpr (std::is_same_v<T, bool> && std::is_same_v<U, bool>) {
691 return Op{}(lhs, rhs);
692 }
693 else if constexpr (std::is_same_v<T, std::string> && std::is_same_v<U, std::string>) {
694 return Op{}(lhs, rhs);
695 }
696 else {
697 return false;
698 }
699 }
700 };
701
706 inline bool operator==(const XLCellValue& lhs, const XLCellValue& rhs)
707 { return std::visit(XLCompareVisitor<std::equal_to<>>{}, lhs.m_value, rhs.m_value); }
708
713 inline bool operator!=(const XLCellValue& lhs, const XLCellValue& rhs)
714 { return std::visit(XLCompareVisitor<std::not_equal_to<>>{}, lhs.m_value, rhs.m_value); }
715
720 inline bool operator<(const XLCellValue& lhs, const XLCellValue& rhs)
721 { return std::visit(XLCompareVisitor<std::less<>>{}, lhs.m_value, rhs.m_value); }
722
727 inline bool operator>(const XLCellValue& lhs, const XLCellValue& rhs)
728 { return std::visit(XLCompareVisitor<std::greater<>>{}, lhs.m_value, rhs.m_value); }
729
734 inline bool operator<=(const XLCellValue& lhs, const XLCellValue& rhs)
735 { return std::visit(XLCompareVisitor<std::less_equal<>>{}, lhs.m_value, rhs.m_value); }
736
741 inline bool operator>=(const XLCellValue& lhs, const XLCellValue& rhs)
742 { return std::visit(XLCompareVisitor<std::greater_equal<>>{}, lhs.m_value, rhs.m_value); }
743
748 inline std::ostream& operator<<(std::ostream& os, const XLCellValue& value)
749 {
750 switch (value.type()) {
752 return os << "";
754 return os << value.get<bool>();
756 return os << value.get<int64_t>();
758 return os << value.get<double>();
760 return os << value.get<std::string>(); // 2025-01-10 BUGFIX: for temporary value objects, this was undefined behavior due
761 // to returning a string_view
763 return os << value.get<OpenXLSX::XLRichText>().plainText();
764 default:
765 return os << "";
766 }
767 }
768
769 inline std::ostream& operator<<(std::ostream& os, const XLCellValueProxy& value)
770 {
771 switch (value.type()) {
773 return os << "";
775 return os << value.get<bool>();
777 return os << value.get<int64_t>();
779 return os << value.get<double>();
781 return os << value.get<std::string>(); // 2025-01-10 BUGFIX: for temporary value objects, this was undefined behavior due
782 // to returning a string_view
784 return os << value.getString(); // getString() for proxy calls VisitXLCellValueTypeToString which handles RichText
785 default:
786 return os << "";
787 }
788 }
789
790} // namespace OpenXLSX
791
792namespace std
793{
794 template<>
795 struct hash<OpenXLSX::XLRichTextRun>
796 {
797 std::size_t operator()(const OpenXLSX::XLRichTextRun& run) const noexcept
798 {
799 std::size_t h = std::hash<std::string>{}(run.text());
800 if (run.bold()) h ^= std::hash<bool>{}(*run.bold()) + 0x9e3779b9 + (h << 6) + (h >> 2);
801 if (run.italic()) h ^= std::hash<bool>{}(*run.italic()) + 0x9e3779b9 + (h << 6) + (h >> 2);
802 return h;
803 }
804 };
805
806 template<>
807 struct hash<OpenXLSX::XLRichText>
808 {
809 std::size_t operator()(const OpenXLSX::XLRichText& rt) const noexcept
810 {
811 std::size_t h = 0;
812 for (const auto& run : rt.runs()) { h ^= std::hash<OpenXLSX::XLRichTextRun>{}(run) + 0x9e3779b9 + (h << 6) + (h >> 2); }
813 return h;
814 }
815 };
816
817 template<>
818 struct hash<OpenXLSX::XLCellValue> // NOLINT
819 {
820 std::size_t operator()(const OpenXLSX::XLCellValue& value) const noexcept
821 {
822 return std::visit([](const auto& v) { return std::hash<std::decay_t<decltype(v)>>{}(v); }, value.getVariant());
823 }
824 };
825} // namespace std
826
827#ifdef _MSC_VER // conditionally enable MSVC specific pragmas to avoid other compilers warning about unknown pragmas
828# pragma warning(pop)
829#endif // _MSC_VER
830
831#endif // OPENXLSX_XLCELLVALUE_HPP
#define OPENXLSX_XLCELLVALUE_FRIEND_STRING_OP(OP, FUNCTOR)
Definition XLCellValue.hpp:92
std::variant< std::string, int64_t, double, bool, OpenXLSX::XLRichText > XLCellValueType
Definition XLCellValue.hpp:27
Definition XLXmlParser.hpp:84
The XLCellValueProxy class is used for proxy (or placeholder) objects for XLCellValue objects.
Definition XLCellValue.hpp:408
XLCellValueProxy & operator=(const T &value)
Templated assignment operator.
Definition XLCellValue.hpp:438
std::string getString() const
Definition XLCellValue.hpp:584
T get() const
Definition XLCellValue.hpp:515
~XLCellValueProxy()
Destructor.
void set(const T &value)
Sets the cell value using an automatically deduced type proxy.
Definition XLCellValue.hpp:503
XLValueType type() const
Get the value type for the cell.
Definition XLCellValue.cpp:245
Class encapsulating a cell value.
Definition XLCellValue.hpp:79
void set(T numberValue)
Templated setter for integral and bool types.
Definition XLCellValue.hpp:248
XLCellValue(XLCellValue &&other) noexcept
Move constructor.
double getDouble() const
get the cell value as a double, regardless of value type
Definition XLCellValue.hpp:326
XLCellValue & operator=(T value)
Templated assignment operator.
Definition XLCellValue.hpp:229
const XLCellValueType & getVariant() const
get the cell value as a std::variant of XLCellValueType
Definition XLCellValue.hpp:356
std::string getString()
get the cell value as a std::string, regardless of value type
Definition XLCellValue.hpp:342
~XLCellValue()
Destructor.
XLCellValue(const XLCellValue &other)
Copy constructor.
XLCellValue & operator=(const XLCellValue &other)
Copy assignment operator.
XLValueType type() const
Get the value type of the current object.
Definition XLCellValue.cpp:94
T get() const
Templated getter.
Definition XLCellValue.hpp:265
XLCellValue(const T &value)
A templated constructor. Any value convertible to a valid cell value can be used as argument.
Definition XLCellValue.hpp:136
XLCellValue & operator=(XLCellValue &&other) noexcept
Move assignment operator.
XLCellValue()
Default constructor.
An implementation class encapsulating the properties and behaviours of a spreadsheet cell.
Definition XLCell.hpp:41
This class encapsulates the concept of an excel file. It is different from the XLWorkbook,...
Definition XLDocument.hpp:82
A class representing a single run of rich text.
Definition XLRichText.hpp:20
A class representing rich text in a cell.
Definition XLRichText.hpp:129
std::string plainText() const
Get the plain text representation of the rich text.
Definition XLRichText.hpp:150
Definition XLException.hpp:41
Definition IZipArchive.hpp:18
bool operator==(const XLCell &lhs, const XLCell &rhs)
Definition XLCell.hpp:304
bool operator!=(const XLCell &lhs, const XLCell &rhs)
Definition XLCell.hpp:311
bool operator<=(const XLCellReference &lhs, const XLCellReference &rhs) noexcept
Asserts whether a cell sequentially precedes or occupies the exact same coordinate as another.
Definition XLCellReference.hpp:244
bool operator<(const XLCellReference &lhs, const XLCellReference &rhs) noexcept
Evaluates precedence primarily by row, then by column, allowing cell ranges to be sorted efficiently ...
Definition XLCellReference.hpp:233
bool operator>=(const XLCellReference &lhs, const XLCellReference &rhs) noexcept
Asserts whether a cell sequentially follows or occupies the exact same coordinate as another.
Definition XLCellReference.hpp:249
XLValueType
Enum defining the valid value types for a an Excel spreadsheet cell.
Definition XLCellValue.hpp:37
bool operator>(const XLCellReference &lhs, const XLCellReference &rhs) noexcept
Inverts the less-than operator logic to verify strict left-to-right, top-to-bottom traversal dominanc...
Definition XLCellReference.hpp:239
std::ostream & operator<<(std::ostream &os, const XLCell &c)
ostream output of XLCell content
Definition XLCell.hpp:319
Definition XLCellIterator.hpp:121
Definition XLCellValue.hpp:41
std::string packageName
Definition XLCellValue.hpp:42
double operator()(std::string v) const
Definition XLCellValue.hpp:52
double operator()(int64_t v) const
Definition XLCellValue.hpp:43
double operator()(double v) const
Definition XLCellValue.hpp:44
double operator()(bool v) const
Definition XLCellValue.hpp:45
double operator()(const OpenXLSX::XLRichText &v) const
Definition XLCellValue.hpp:47
Definition XLCellValue.hpp:65
std::string operator()(bool v) const
Definition XLCellValue.hpp:69
std::string operator()(int64_t v) const
Definition XLCellValue.hpp:67
std::string operator()(double v) const
Definition XLCellValue.hpp:68
std::string operator()(std::string v) const
Definition XLCellValue.hpp:72
std::string packageName
Definition XLCellValue.hpp:66
std::string operator()(const XLRichText &v) const
Definition XLCellValue.hpp:71
std::size_t operator()(const OpenXLSX::XLCellValue &value) const noexcept
Definition XLCellValue.hpp:820
std::size_t operator()(const OpenXLSX::XLRichTextRun &run) const noexcept
Definition XLCellValue.hpp:797
std::size_t operator()(const OpenXLSX::XLRichText &rt) const noexcept
Definition XLCellValue.hpp:809