11#ifndef OPENXLSX_XLCELLRANGE_HPP
12#define OPENXLSX_XLCELLRANGE_HPP
16# pragma warning(disable : 4251)
17# pragma warning(disable : 4275)
24#include "OpenXLSX-Exports.hpp"
80 [[nodiscard]] std::string
address()
const;
82 [[nodiscard]] uint32_t
numRows()
const;
105 std::vector<std::vector<T>>
getValue()
const;
108 void setValue(
const std::vector<std::vector<T>>& matrix);
112 [[nodiscard]]
bool empty()
const;
123 typename = std::enable_if_t<
124 std::is_integral_v<T> or std::is_floating_point_v<T> or std::is_same_v<std::decay_t<T>, std::string> ||
125 std::is_same_v<std::decay_t<T>, std::string_view> or std::is_same_v<std::decay_t<T>,
const char*> ||
126 std::is_same_v<std::decay_t<T>,
char*> or std::is_same_v<T, XLDateTime>>>
129 for (
auto it =
begin(); it !=
end(); ++it) it->value() = value;
151 std::vector<XLStyleIndex> m_columnStyles;
165 std::vector<std::vector<T>> matrix;
173 for (
auto& cell : *
this) {
174 uint32_t r = cell.cellReference().row() - startRow;
175 uint16_t c = cell.cellReference().column() - startCol;
176 matrix[r][c] = cell.value().get<T>();
184 if (matrix.empty() || matrix[0].empty())
return;
189 for (
auto& cell : *
this) {
190 uint32_t r = cell.cellReference().row() - startRow;
191 uint16_t c = cell.cellReference().column() - startCol;
192 if (r < matrix.size() && c < matrix[r].size()) { cell.value() = matrix[r][c]; }
Represents a rectangular area of cells within a worksheet.
Definition XLCellRange.hpp:40
XLCellReference topLeft() const
Definition XLCellRange.cpp:90
uint32_t numRows() const
Definition XLCellRange.cpp:109
void clear()
Clears the values of all cells within the range.
Definition XLCellRange.cpp:142
XLCellReference bottomRight() const
Definition XLCellRange.cpp:95
XLCellIterator begin() const
Definition XLCellRange.cpp:127
uint16_t numColumns() const
Definition XLCellRange.cpp:118
XLCellRange()
Constructs an uninitialized range.
Definition XLCellRange.cpp:24
void setValue(const std::vector< std::vector< T > > &matrix)
Definition XLCellRange.hpp:182
void applyStyle(const XLStyle &style)
Apply a high-level style to all cells within this range.
Definition XLCellRange.cpp:174
XLCellRange(XLCellRange &&other) noexcept=default
std::string address() const
Definition XLCellRange.cpp:100
XLCellRange(const XLCellRange &other)=default
void fetchColumnStyles()
Scans the worksheet for column-level styles and caches them.
Definition XLCellRange.cpp:59
std::vector< std::vector< T > > getValue() const
Read the range into a 2D matrix of type T.
Definition XLCellRange.hpp:163
bool empty() const
Returns true if the range is uninitialized or points to an invalid worksheet node.
Definition XLCellRange.cpp:137
XLCellRange & operator=(XLCellRange &&other) noexcept=default
XLCellRange & operator=(const XLCellRange &other)=default
XLCellRange & operator=(T value)
Assigns a single value to every cell in the range.
Definition XLCellRange.hpp:127
friend class XLCellIterator
Definition XLCellRange.hpp:41
void setBorderOutline(XLLineStyle style, XLColor color)
Set border style specifically for the outer edges of this range.
Definition XLCellRange.cpp:179
XLCellIterator end() const
Definition XLCellRange.cpp:132
Definition XLCellReference.hpp:44
uint32_t row() const noexcept
Get the row number of the XLCellReference.
Definition XLCellReference.cpp:157
uint16_t column() const noexcept
Get the column number of the XLCellReference.
Definition XLCellReference.cpp:175
Definition XLColor.hpp:32
This class encapsulate the Excel concept of Shared Strings. In Excel, instead of havig individual str...
Definition XLSharedStrings.hpp:78
Definition IXLCellProvider.hpp:24
OpenXLSX_xml_node XMLNode
Definition XLXmlParser.hpp:64
size_t XLStyleIndex
Definition XLStyles_Common.hpp:36
XLLineStyle
Definition XLStyles_Common.hpp:157
std::reference_wrapper< const XLSharedStrings > XLSharedStringsRef
Definition XLSharedStrings.hpp:67
A high-level, human-ergonomic structure representing the styling of a cell or range....
Definition XLStyle.hpp:29