OpenXLSX 1.9.1
Loading...
Searching...
No Matches
OpenXLSX::XLCellReference Class Referencefinal

#include <XLCellReference.hpp>

Public Member Functions

 XLCellReference (std::string_view cellAddress="")
 Constructor taking a cell address as argument.
 
 XLCellReference (uint32_t row, uint16_t column)
 Constructor taking the cell coordinates as arguments.
 
 XLCellReference (uint32_t row, std::string_view column)
 Constructor taking the row number and the column letter as arguments.
 
 XLCellReference (const XLCellReference &other)
 Copy constructor.
 
 XLCellReference (XLCellReference &&other) noexcept
 
 ~XLCellReference ()
 Destructor. Default implementation used.
 
XLCellReferenceoperator= (const XLCellReference &other)
 Assignment operator.
 
XLCellReferenceoperator= (XLCellReference &&other) noexcept
 
XLCellReferenceoperator++ ()
 
XLCellReference operator++ (int)
 
XLCellReferenceoperator-- ()
 
XLCellReference operator-- (int)
 
uint32_t row () const noexcept
 Get the row number of the XLCellReference.
 
void setRow (uint32_t row)
 Set the row number for the XLCellReference.
 
uint16_t column () const noexcept
 Get the column number of the XLCellReference.
 
void setColumn (uint16_t column)
 Set the column number of the XLCellReference.
 
void setRowAndColumn (uint32_t row, uint16_t column)
 Set both row and column number of the XLCellReference.
 
std::string address () const
 Get the address of the XLCellReference.
 
void setAddress (std::string_view address)
 Set the address of the XLCellReference.
 

Static Public Member Functions

static std::string rowAsString (uint32_t row)
 
static uint32_t rowAsNumber (std::string_view row)
 
static std::string columnAsString (uint16_t column)
 Static helper function to convert column number to column letter (e.g. column 1 becomes 'A')
 
static uint16_t columnAsNumber (std::string_view column)
 Static helper function to convert column letter to column number (e.g. column 'A' becomes 1)
 
static XLCoordinates coordinatesFromAddress (std::string_view address)
 Static helper function to convert cell address to coordinates.
 

Friends

bool operator== (const XLCellReference &lhs, const XLCellReference &rhs) noexcept
 Determines exact coordinate identity, allowing comparisons without resolving their DOM node equivalence.
 
bool operator!= (const XLCellReference &lhs, const XLCellReference &rhs) noexcept
 Detects coordinate divergence, effectively identical to !(lhs == rhs).
 
bool operator< (const XLCellReference &lhs, const XLCellReference &rhs) noexcept
 Evaluates precedence primarily by row, then by column, allowing cell ranges to be sorted efficiently and sequentially from left-to-right, top-to-bottom.
 
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 dominance.
 
bool operator<= (const XLCellReference &lhs, const XLCellReference &rhs) noexcept
 Asserts whether a cell sequentially precedes or occupies the exact same coordinate as another.
 
bool operator>= (const XLCellReference &lhs, const XLCellReference &rhs) noexcept
 Asserts whether a cell sequentially follows or occupies the exact same coordinate as another.
 

Constructor & Destructor Documentation

◆ XLCellReference() [1/5]

XLCellReference::XLCellReference ( std::string_view  cellAddress = "")

Constructor taking a cell address as argument.

Parameters
cellAddressThe address of the cell, e.g. 'A1'.

Initializes a reference using an Excel-style coordinate string (e.g., 'A1'). Serves as the primary parser for cell identities read directly from the DOM.

Initializes a reference using an Excel-style coordinate string (e.g., 'A1'). Serves as the primary parser for cell identities read directly from the DOM.

◆ XLCellReference() [2/5]

XLCellReference::XLCellReference ( uint32_t  row,
uint16_t  column 
)

Constructor taking the cell coordinates as arguments.

Parameters
rowThe row number of the cell.
columnThe column number of the cell.

Directly binds explicit row and column indices. Offers higher performance than string parsing when iterating systematically (e.g., over a numerical range).

◆ XLCellReference() [3/5]

XLCellReference::XLCellReference ( uint32_t  row,
std::string_view  column 
)

Constructor taking the row number and the column letter as arguments.

Parameters
rowThe row number of the cell.
columnThe column letter of the cell.

Binds a hybrid coordinate system using explicit numeric rows and alphabetical column headers, typically for convenient manual cell selection.

◆ XLCellReference() [4/5]

XLCellReference::XLCellReference ( const XLCellReference other)
default

Copy constructor.

Parameters
otherThe object to be copied.

◆ XLCellReference() [5/5]

XLCellReference::XLCellReference ( XLCellReference &&  other)
defaultnoexcept
Parameters
other

◆ ~XLCellReference()

XLCellReference::~XLCellReference ( )
default

Destructor. Default implementation used.

Member Function Documentation

◆ address()

std::string XLCellReference::address ( ) const

Get the address of the XLCellReference.

Returns
The address, e.g. 'A1'

Provides the cached Excel-style cell identifier (e.g. 'A1'), which is directly compliant with the OOXML <c r="A1"> coordinate schema requirement.

◆ column()

uint16_t XLCellReference::column ( ) const
noexcept

Get the column number of the XLCellReference.

Returns
The column number.

Provides the raw integer index representing the 1-based horizontal position within the worksheet.

◆ columnAsNumber()

uint16_t XLCellReference::columnAsNumber ( std::string_view  column)
static

Static helper function to convert column letter to column number (e.g. column 'A' becomes 1)

Parameters
columnThe column letter, e.g. 'A'
Returns
The column number.

Performs Base26 reverse-translation from alphabetical column notation into a numeric index. Throws XLInputError for non-alphabet characters or violations of maximum bounds.

◆ columnAsString()

std::string XLCellReference::columnAsString ( uint16_t  column)
static

Static helper function to convert column number to column letter (e.g. column 1 becomes 'A')

Parameters
columnThe column number.
Returns
The column letter

Translates a 1-based horizontal integer index into the standard Excel alphabetical column notation (A, B, ..., Z, AA, AB...). Required for generating compliant OOXML XML nodes.

◆ coordinatesFromAddress()

XLCoordinates XLCellReference::coordinatesFromAddress ( std::string_view  address)
static

Static helper function to convert cell address to coordinates.

Parameters
addressThe address to be converted, e.g. 'A1'
Returns
A std::pair<row, column>

Splits a consolidated alphanumeric coordinate (e.g., 'A1') into discrete row and column components. Throws if the format is malformed or out of bounds.

◆ operator++() [1/2]

XLCellReference & XLCellReference::operator++ ( )
Returns

◆ operator++() [2/2]

XLCellReference XLCellReference::operator++ ( int  )
Returns

◆ operator--() [1/2]

XLCellReference & XLCellReference::operator-- ( )
Returns

◆ operator--() [2/2]

XLCellReference XLCellReference::operator-- ( int  )
Returns

◆ operator=() [1/2]

XLCellReference & XLCellReference::operator= ( const XLCellReference other)
default

Assignment operator.

Parameters
otherThe object to be copied/assigned.
Returns
A reference to the new object.

◆ operator=() [2/2]

XLCellReference & XLCellReference::operator= ( XLCellReference &&  other)
defaultnoexcept
Parameters
other
Returns

◆ row()

uint32_t XLCellReference::row ( ) const
noexcept

Get the row number of the XLCellReference.

Returns
The row.

Provides the raw integer index representing the 1-based vertical position within the worksheet.

◆ rowAsNumber()

uint32_t XLCellReference::rowAsNumber ( std::string_view  row)
static
Parameters
row
Returns

Fast integer parser specifically meant to process the numeric half of an Excel cell address.

◆ rowAsString()

std::string XLCellReference::rowAsString ( uint32_t  row)
static
Parameters
row
Returns

Highly optimized formatter converting integer indices to strings (using std::to_chars if available) to minimize serialization overhead.

◆ setAddress()

void XLCellReference::setAddress ( std::string_view  address)

Set the address of the XLCellReference.

Parameters
addressThe address, e.g. 'A1'
Precondition
The address input string must be a valid Excel cell reference. Otherwise the behaviour is undefined.

Parses an Excel-style coordinate string (e.g., 'A1') and breaks it down into raw 1-based vertical and horizontal integer components for internal programmatic routing.

◆ setColumn()

void XLCellReference::setColumn ( uint16_t  column)

Set the column number of the XLCellReference.

Parameters
columnThe column number.

Mutates the 1-based horizontal index. Validates the boundary and keeps the cached string address in sync.

◆ setRow()

void XLCellReference::setRow ( uint32_t  row)

Set the row number for the XLCellReference.

Parameters
rowThe row number.

Mutates the 1-based vertical index. Automatically recalculates the full Excel-style string address to keep the internal state in sync.

◆ setRowAndColumn()

void XLCellReference::setRowAndColumn ( uint32_t  row,
uint16_t  column 
)

Set both row and column number of the XLCellReference.

Parameters
rowThe row number.
columnThe column number.

Re-binds the object to an entirely new coordinate, bypassing dual string recalculation by batching the integer mutations together.

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const XLCellReference lhs,
const XLCellReference rhs 
)
friend

Detects coordinate divergence, effectively identical to !(lhs == rhs).

◆ operator<

bool operator< ( const XLCellReference lhs,
const XLCellReference rhs 
)
friend

Evaluates precedence primarily by row, then by column, allowing cell ranges to be sorted efficiently and sequentially from left-to-right, top-to-bottom.

◆ operator<=

bool operator<= ( const XLCellReference lhs,
const XLCellReference rhs 
)
friend

Asserts whether a cell sequentially precedes or occupies the exact same coordinate as another.

◆ operator==

bool operator== ( const XLCellReference lhs,
const XLCellReference rhs 
)
friend

Determines exact coordinate identity, allowing comparisons without resolving their DOM node equivalence.

◆ operator>

bool operator> ( const XLCellReference lhs,
const XLCellReference rhs 
)
friend

Inverts the less-than operator logic to verify strict left-to-right, top-to-bottom traversal dominance.

◆ operator>=

bool operator>= ( const XLCellReference lhs,
const XLCellReference rhs 
)
friend

Asserts whether a cell sequentially follows or occupies the exact same coordinate as another.


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