xlnt
Public Types | Public Member Functions | List of all members
xlnt::range Class Reference

A range is a 2D collection of cells with defined extens that can be iterated upon. More...

#include <range.hpp>

Public Types

using iterator = range_iterator
 Alias for the iterator type More...
 
using const_iterator = const_range_iterator
 Alias for the const iterator type More...
 
using reverse_iterator = std::reverse_iterator< iterator >
 Alias for the reverse iterator type More...
 
using const_reverse_iterator = std::reverse_iterator< const_iterator >
 Alias for the const reverse iterator type More...
 

Public Member Functions

 range (worksheet ws, const range_reference &reference, major_order order=major_order::row, bool skip_null=false)
 Constructs a range on the given worksheet. More...
 
 ~range ()
 Desctructor More...
 
 range (const range &)=default
 Default copy constructor. More...
 
void clear_cells ()
 Erases all cell data from the worksheet for cells within this range. More...
 
cell_vector vector (std::size_t n)
 Returns a vector pointing to the n-th row or column in this range (depending on major order). More...
 
const cell_vector vector (std::size_t n) const
 Returns a vector pointing to the n-th row or column in this range (depending on major order). More...
 
class cell cell (const cell_reference &ref)
 Returns a cell in the range relative to its top left cell. More...
 
const class cell cell (const cell_reference &ref) const
 Returns a cell in the range relative to its top left cell. More...
 
const worksheettarget_worksheet () const
 The worksheet this range targets More...
 
range_reference reference () const
 Returns the reference defining the bounds of this range. More...
 
std::size_t length () const
 Returns the number of rows or columns in this range (depending on major order). More...
 
bool contains (const cell_reference &ref)
 Returns true if the given cell exists in the parent worksheet of this range. More...
 
range alignment (const xlnt::alignment &new_alignment)
 Sets the alignment of all cells in the range to new_alignment and returns the range. More...
 
range border (const xlnt::border &new_border)
 Sets the border of all cells in the range to new_border and returns the range. More...
 
range fill (const xlnt::fill &new_fill)
 Sets the fill of all cells in the range to new_fill and returns the range. More...
 
range font (const xlnt::font &new_font)
 Sets the font of all cells in the range to new_font and returns the range. More...
 
range number_format (const xlnt::number_format &new_number_format)
 Sets the number format of all cells in the range to new_number_format and returns the range. More...
 
range protection (const xlnt::protection &new_protection)
 Sets the protection of all cells in the range to new_protection and returns the range. More...
 
range style (const class style &new_style)
 Sets the named style applied to all cells in this range to a style named style_name. More...
 
range style (const std::string &style_name)
 Sets the named style applied to all cells in this range to a style named style_name. If this style has not been previously created in the workbook, a key_not_found exception will be thrown. More...
 
xlnt::conditional_format conditional_format (const condition &when)
 
cell_vector front ()
 Returns the first row or column in this range. More...
 
const cell_vector front () const
 Returns the first row or column in this range. More...
 
cell_vector back ()
 Returns the last row or column in this range. More...
 
const cell_vector back () const
 Returns the last row or column in this range. More...
 
iterator begin ()
 Returns an iterator to the first row or column in this range. More...
 
iterator end ()
 Returns an iterator to one past the last row or column in this range. More...
 
const_iterator begin () const
 Returns an iterator to the first row or column in this range. More...
 
const_iterator end () const
 Returns an iterator to one past the last row or column in this range. More...
 
const_iterator cbegin () const
 Returns an iterator to the first row or column in this range. More...
 
const_iterator cend () const
 Returns an iterator to one past the last row or column in this range. More...
 
reverse_iterator rbegin ()
 Returns a reverse iterator to the first row or column in this range. More...
 
reverse_iterator rend ()
 Returns a reverse iterator to one past the last row or column in this range. More...
 
const_reverse_iterator rbegin () const
 Returns a reverse iterator to the first row or column in this range. More...
 
const_reverse_iterator rend () const
 Returns a reverse iterator to one past the last row or column in this range. More...
 
const_reverse_iterator crbegin () const
 Returns a reverse iterator to the first row or column in this range. More...
 
const_reverse_iterator crend () const
 Returns a reverse iterator to one past the last row or column in this range. More...
 
void apply (std::function< void(class cell)> f)
 Applies function f to all cells in the range More...
 
cell_vector operator[] (std::size_t n)
 Returns the n-th row or column in this range. More...
 
const cell_vector operator[] (std::size_t n) const
 Returns the n-th row or column in this range. More...
 
bool operator== (const range &comparand) const
 Returns true if this range is equivalent to comparand. More...
 
bool operator!= (const range &comparand) const
 Returns true if this range is not equivalent to comparand. More...
 

Detailed Description

A range is a 2D collection of cells with defined extens that can be iterated upon.

Member Typedef Documentation

◆ const_iterator

Alias for the const iterator type

◆ const_reverse_iterator

using xlnt::range::const_reverse_iterator = std::reverse_iterator<const_iterator>

Alias for the const reverse iterator type

◆ iterator

Alias for the iterator type

◆ reverse_iterator

using xlnt::range::reverse_iterator = std::reverse_iterator<iterator>

Alias for the reverse iterator type

Constructor & Destructor Documentation

◆ range() [1/2]

xlnt::range::range ( worksheet  ws,
const range_reference reference,
major_order  order = major_order::row,
bool  skip_null = false 
)

Constructs a range on the given worksheet.

◆ ~range()

xlnt::range::~range ( )

Desctructor

◆ range() [2/2]

xlnt::range::range ( const range )
default

Default copy constructor.

Member Function Documentation

◆ alignment()

range xlnt::range::alignment ( const xlnt::alignment new_alignment)

Sets the alignment of all cells in the range to new_alignment and returns the range.

◆ apply()

void xlnt::range::apply ( std::function< void(class cell)>  f)

Applies function f to all cells in the range

◆ back() [1/2]

cell_vector xlnt::range::back ( )

Returns the last row or column in this range.

◆ back() [2/2]

const cell_vector xlnt::range::back ( ) const

Returns the last row or column in this range.

◆ begin() [1/2]

iterator xlnt::range::begin ( )

Returns an iterator to the first row or column in this range.

◆ begin() [2/2]

const_iterator xlnt::range::begin ( ) const

Returns an iterator to the first row or column in this range.

◆ border()

range xlnt::range::border ( const xlnt::border new_border)

Sets the border of all cells in the range to new_border and returns the range.

◆ cbegin()

const_iterator xlnt::range::cbegin ( ) const

Returns an iterator to the first row or column in this range.

◆ cell() [1/2]

class cell xlnt::range::cell ( const cell_reference ref)

Returns a cell in the range relative to its top left cell.

◆ cell() [2/2]

const class cell xlnt::range::cell ( const cell_reference ref) const

Returns a cell in the range relative to its top left cell.

◆ cend()

const_iterator xlnt::range::cend ( ) const

Returns an iterator to one past the last row or column in this range.

◆ clear_cells()

void xlnt::range::clear_cells ( )

Erases all cell data from the worksheet for cells within this range.

◆ conditional_format()

xlnt::conditional_format xlnt::range::conditional_format ( const condition when)

◆ contains()

bool xlnt::range::contains ( const cell_reference ref)

Returns true if the given cell exists in the parent worksheet of this range.

◆ crbegin()

const_reverse_iterator xlnt::range::crbegin ( ) const

Returns a reverse iterator to the first row or column in this range.

◆ crend()

const_reverse_iterator xlnt::range::crend ( ) const

Returns a reverse iterator to one past the last row or column in this range.

◆ end() [1/2]

iterator xlnt::range::end ( )

Returns an iterator to one past the last row or column in this range.

◆ end() [2/2]

const_iterator xlnt::range::end ( ) const

Returns an iterator to one past the last row or column in this range.

◆ fill()

range xlnt::range::fill ( const xlnt::fill new_fill)

Sets the fill of all cells in the range to new_fill and returns the range.

◆ font()

range xlnt::range::font ( const xlnt::font new_font)

Sets the font of all cells in the range to new_font and returns the range.

◆ front() [1/2]

cell_vector xlnt::range::front ( )

Returns the first row or column in this range.

◆ front() [2/2]

const cell_vector xlnt::range::front ( ) const

Returns the first row or column in this range.

◆ length()

std::size_t xlnt::range::length ( ) const

Returns the number of rows or columns in this range (depending on major order).

◆ number_format()

range xlnt::range::number_format ( const xlnt::number_format new_number_format)

Sets the number format of all cells in the range to new_number_format and returns the range.

◆ operator!=()

bool xlnt::range::operator!= ( const range comparand) const

Returns true if this range is not equivalent to comparand.

◆ operator==()

bool xlnt::range::operator== ( const range comparand) const

Returns true if this range is equivalent to comparand.

◆ operator[]() [1/2]

cell_vector xlnt::range::operator[] ( std::size_t  n)

Returns the n-th row or column in this range.

◆ operator[]() [2/2]

const cell_vector xlnt::range::operator[] ( std::size_t  n) const

Returns the n-th row or column in this range.

◆ protection()

range xlnt::range::protection ( const xlnt::protection new_protection)

Sets the protection of all cells in the range to new_protection and returns the range.

◆ rbegin() [1/2]

reverse_iterator xlnt::range::rbegin ( )

Returns a reverse iterator to the first row or column in this range.

◆ rbegin() [2/2]

const_reverse_iterator xlnt::range::rbegin ( ) const

Returns a reverse iterator to the first row or column in this range.

◆ reference()

range_reference xlnt::range::reference ( ) const

Returns the reference defining the bounds of this range.

◆ rend() [1/2]

reverse_iterator xlnt::range::rend ( )

Returns a reverse iterator to one past the last row or column in this range.

◆ rend() [2/2]

const_reverse_iterator xlnt::range::rend ( ) const

Returns a reverse iterator to one past the last row or column in this range.

◆ style() [1/2]

range xlnt::range::style ( const class style new_style)

Sets the named style applied to all cells in this range to a style named style_name.

◆ style() [2/2]

range xlnt::range::style ( const std::string &  style_name)

Sets the named style applied to all cells in this range to a style named style_name. If this style has not been previously created in the workbook, a key_not_found exception will be thrown.

◆ target_worksheet()

const worksheet& xlnt::range::target_worksheet ( ) const

The worksheet this range targets

◆ vector() [1/2]

cell_vector xlnt::range::vector ( std::size_t  n)

Returns a vector pointing to the n-th row or column in this range (depending on major order).

◆ vector() [2/2]

const cell_vector xlnt::range::vector ( std::size_t  n) const

Returns a vector pointing to the n-th row or column in this range (depending on major order).


The documentation for this class was generated from the following file: