OpenXLSX 1.9.1
Loading...
Searching...
No Matches
OpenXLSX::XLRow Class Reference

The XLRow class represent a row in an Excel spreadsheet. Using XLRow objects, various row formatting options can be set and modified. More...

#include <XLRow.hpp>

Public Member Functions

 XLRow ()
 Default constructor.
 
 XLRow (const XMLNode &rowNode, const XLSharedStrings &sharedStrings, XLWorksheet *wks=nullptr)
 
 XLRow (const XLRow &other)
 Copy Constructor.
 
 XLRow (XLRow &&other) noexcept
 Move Constructor.
 
 ~XLRow ()
 Destructor.
 
XLRowoperator= (const XLRow &other)
 Copy assignment operator.
 
XLRowoperator= (XLRow &&other) noexcept
 Move assignment operator.
 
bool empty () const
 test if row object has no (valid) content
 
 operator bool () const
 opposite of empty()
 
double height () const
 Get the height of the row.
 
void setHeight (float height)
 Set the height of the row.
 
float descent () const
 Get the descent of the row, which is the vertical distance in pixels from the bottom of the cells in the current row to the typographical baseline of the cell content.
 
void setDescent (float descent)
 Set the descent of the row, which is he vertical distance in pixels from the bottom of the cells in the current row to the typographical baseline of the cell content.
 
bool isHidden () const
 Is the row hidden?
 
void setHidden (bool state)
 Set the row to be hidden or visible.
 
uint8_t outlineLevel () const
 Get the outline level of the row.
 
void setOutlineLevel (uint8_t level)
 Set the outline level of the row.
 
bool isCollapsed () const
 Is the row collapsed?
 
void setCollapsed (bool state)
 Set the row to be collapsed or expanded.
 
uint32_t rowNumber () const
 
uint16_t cellCount () const
 Get the number of cells in the row.
 
XLRowDataProxyvalues ()
 
const XLRowDataProxyvalues () const
 
template<typename T >
values () const
 
XLRowDataRange cells () const
 
XLRowDataRange cells (uint16_t cellCount) const
 
XLRowDataRange cells (uint16_t firstCell, uint16_t lastCell) const
 
XLCell findCell (uint16_t columNumber)
 Find a cell at columNumber, or return an empty cell.
 
XLStyleIndex format () const
 Get the array index of xl/styles.xml:<styleSheet>:<cellXfs> for the style assigned to the row. This value is stored in the row attributes like so: s="2".
 
bool setFormat (XLStyleIndex cellFormatIndex)
 Set the row style as a reference to the array index of xl/styles.xml:<styleSheet>:<cellXfs>
 

Friends

class XLRowIterator
 
class XLRowDataProxy
 
bool operator== (const XLRow &lhs, const XLRow &rhs)
 
bool operator!= (const XLRow &lhs, const XLRow &rhs)
 
bool operator< (const XLRow &lhs, const XLRow &rhs)
 
bool operator> (const XLRow &lhs, const XLRow &rhs)
 
bool operator<= (const XLRow &lhs, const XLRow &rhs)
 
bool operator>= (const XLRow &lhs, const XLRow &rhs)
 

Detailed Description

The XLRow class represent a row in an Excel spreadsheet. Using XLRow objects, various row formatting options can be set and modified.

Constructor & Destructor Documentation

◆ XLRow() [1/4]

OpenXLSX::XLRow::XLRow ( )

Default constructor.

◆ XLRow() [2/4]

OpenXLSX::XLRow::XLRow ( const XMLNode rowNode,
const XLSharedStrings sharedStrings,
XLWorksheet wks = nullptr 
)
Parameters
rowNode
sharedStrings

Constructs a new XLRow object from information in the underlying XML file. A pointer to the corresponding node in the underlying XML file must be provided.

◆ XLRow() [3/4]

OpenXLSX::XLRow::XLRow ( const XLRow other)

Copy Constructor.

Note
The copy constructor is explicitly deleted

◆ XLRow() [4/4]

OpenXLSX::XLRow::XLRow ( XLRow &&  other)
noexcept

Move Constructor.

Note
The move constructor has been explicitly deleted.

Because the m_rowDataProxy variable is tied to an exact XLRow object, the move operation is not a 'pure' move, as a new XLRowDataProxy has to be constructed.

◆ ~XLRow()

OpenXLSX::XLRow::~XLRow ( )
default

Destructor.

Note
The destructor has a default implementation.

Member Function Documentation

◆ cellCount()

uint16_t OpenXLSX::XLRow::cellCount ( ) const

Get the number of cells in the row.

Returns
The number of cells in the row.

Get the number of cells in the row, by returning the size of the m_cells vector.

◆ cells() [1/3]

XLRowDataRange OpenXLSX::XLRow::cells ( ) const
Returns

◆ cells() [2/3]

XLRowDataRange OpenXLSX::XLRow::cells ( uint16_t  cellCount) const
Parameters
cellCount
Returns

◆ cells() [3/3]

XLRowDataRange OpenXLSX::XLRow::cells ( uint16_t  firstCell,
uint16_t  lastCell 
) const
Parameters
firstCell
lastCell
Returns

◆ descent()

float OpenXLSX::XLRow::descent ( ) const

Get the descent of the row, which is the vertical distance in pixels from the bottom of the cells in the current row to the typographical baseline of the cell content.

Returns
The row descent.

Retrieves the row's vertical descent value. This is used by Excel's rendering engine to appropriately position text baselines for certain fonts.

◆ empty()

bool OpenXLSX::XLRow::empty ( ) const

test if row object has no (valid) content

Returns

◆ findCell()

XLCell OpenXLSX::XLRow::findCell ( uint16_t  columnNumber)

Find a cell at columNumber, or return an empty cell.

Parameters
columNumberThe column at which to check for an existing cell
Returns
An XLCell object (that bool-evaluates to false if cell was not found)

Find & return a cell in indicated column

◆ format()

XLStyleIndex OpenXLSX::XLRow::format ( ) const

Get the array index of xl/styles.xml:<styleSheet>:<cellXfs> for the style assigned to the row. This value is stored in the row attributes like so: s="2".

Returns
The index of the applicable format style

Determine the value of the style attribute "s" - if attribute does not exist, return default value

◆ height()

double OpenXLSX::XLRow::height ( ) const

Get the height of the row.

Returns
the row height.

Retrieves the explicitly assigned height of the row. If no custom height is set, it defaults to 15.0.

◆ isCollapsed()

bool OpenXLSX::XLRow::isCollapsed ( ) const

Is the row collapsed?

Returns
true if the row is collapsed.

Checks if the row carries the collapsed marker. In Excel, this flag is typically placed on the summary row adjacent to a hidden group to render the '+' expansion UI button.

◆ isHidden()

bool OpenXLSX::XLRow::isHidden ( ) const

Is the row hidden?

Returns
The state of the row.

Retrieves the row's visibility state. Hidden rows remain in the document and participate in calculations, but are not rendered in the spreadsheet UI.

◆ operator bool()

OpenXLSX::XLRow::operator bool ( ) const
explicit

opposite of empty()

Returns

◆ operator=() [1/2]

XLRow & OpenXLSX::XLRow::operator= ( const XLRow other)

Copy assignment operator.

Note
The copy assignment operator is explicitly deleted.

◆ operator=() [2/2]

XLRow & OpenXLSX::XLRow::operator= ( XLRow &&  other)
noexcept

Move assignment operator.

Note
The move assignment operator has been explicitly deleted.

Because the m_rowDataProxy variable is tied to an exact XLRow object, the move operation is not a 'pure' move, as a new XLRowDataProxy has to be constructed.

◆ outlineLevel()

uint8_t OpenXLSX::XLRow::outlineLevel ( ) const

Get the outline level of the row.

Returns
The outline level (0-7).

Retrieves the row's outline level (0-7), which determines its nesting depth within a hierarchical grouping structure.

◆ rowNumber()

uint32_t OpenXLSX::XLRow::rowNumber ( ) const
Returns
Note
2024-08-18: changed return type of rowNumber to uint32_t CAUTION: there is no validity check on the underlying XML (nor was there ever one in case a value was inconsistent with OpenXLSX::MAX_ROWS)

◆ setCollapsed()

void OpenXLSX::XLRow::setCollapsed ( bool  state)

Set the row to be collapsed or expanded.

Parameters
stateThe collapsed state of the row.

Controls the expansion UI marker ('+' or '-') for grouped rows. This must be set on the summary row that remains visible when the corresponding detailed rows are hidden.

◆ setDescent()

void OpenXLSX::XLRow::setDescent ( float  descent)

Set the descent of the row, which is he vertical distance in pixels from the bottom of the cells in the current row to the typographical baseline of the cell content.

Parameters
descentThe row descent.

Sets the typography descent attribute. This fine-tunes how far characters drop below the text baseline in this specific row, maintaining exact layout fidelity.

◆ setFormat()

bool OpenXLSX::XLRow::setFormat ( XLStyleIndex  cellFormatIndex)

Set the row style as a reference to the array index of xl/styles.xml:<styleSheet>:<cellXfs>

Set the row style as a reference to the array index of xl/styles.xml:<styleSheet>:<cellXfs> If the style attribute "s" does not exist, create it.

Parameters
cellFormatIndexThe style to set, corresponding to the index of XLStyles::cellStyles()
Returns
true on success, false on failure

◆ setHeight()

void OpenXLSX::XLRow::setHeight ( float  height)

Set the height of the row.

Parameters
heightThe height of the row.

Modifies the visual height of the row. The 'customHeight' attribute must be explicitly set to 1, otherwise MS Excel will ignore the 'ht' value and auto-fit the row height based on cell contents.

◆ setHidden()

void OpenXLSX::XLRow::setHidden ( bool  state)

Set the row to be hidden or visible.

Parameters
stateThe state of the row.

Modifies the visual state of the row. Typically used for applying filters or manually hiding rows without deleting their underlying data or breaking formulas.

◆ setOutlineLevel()

void OpenXLSX::XLRow::setOutlineLevel ( uint8_t  level)

Set the outline level of the row.

Parameters
levelThe outline level (0-7).

Applies a grouping depth to the row. Values > 7 are capped, as MS Excel only supports up to 8 levels (0-7). Setting the level to 0 completely removes the outline grouping attribute.

◆ values() [1/3]

XLRowDataProxy & OpenXLSX::XLRow::values ( )
Returns

◆ values() [2/3]

const XLRowDataProxy & OpenXLSX::XLRow::values ( ) const
Returns

◆ values() [3/3]

template<typename T >
T OpenXLSX::XLRow::values ( ) const
inline
Template Parameters
T
Returns

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const XLRow lhs,
const XLRow rhs 
)
friend
Parameters
lhs
rhs
Returns

◆ operator<

bool operator< ( const XLRow lhs,
const XLRow rhs 
)
friend
Parameters
lhs
rhs
Returns

◆ operator<=

bool operator<= ( const XLRow lhs,
const XLRow rhs 
)
friend
Parameters
lhs
rhs
Returns

◆ operator==

bool operator== ( const XLRow lhs,
const XLRow rhs 
)
friend
Parameters
lhs
rhs
Returns

◆ operator>

bool operator> ( const XLRow lhs,
const XLRow rhs 
)
friend
Parameters
lhs
rhs
Returns

◆ operator>=

bool operator>= ( const XLRow lhs,
const XLRow rhs 
)
friend
Parameters
lhs
rhs
Returns

◆ XLRowDataProxy

friend class XLRowDataProxy
friend

◆ XLRowIterator

friend class XLRowIterator
friend

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