OpenXLSX 1.12.1
Modern C++ Excel Library (Fork of OpenXLSX by Kenneth Troldal Balslev)
Loading...
Searching...
No Matches
OpenXLSX::XLFormulaArg Class Reference

Lightweight formula evaluation engine. More...

#include <XLFormulaEngine.hpp>

Data Structures

class  Iterator

Public Types

enum class  Type { Empty , Scalar , Array , LazyRange }

Public Member Functions

 XLFormulaArg ()=default
 XLFormulaArg (XLCellValue v)
 XLFormulaArg (std::vector< XLCellValue > arr)
 Construct a column vector (N×1) from a flat list.
 XLFormulaArg (std::vector< XLCellValue > data, size_t rows, size_t cols)
 Construct a dense row-major 2-D array.
 XLFormulaArg (uint32_t r1, uint32_t r2, uint16_t c1, uint16_t c2, std::string sheetName, const std::function< XLCellValue(std::string_view)> *resolver)
Type type () const
size_t rows () const
size_t cols () const
uint32_t firstRow () const noexcept
 Return the 1-based row of the top-left cell (LazyRange only; 0 for other types).
uint16_t firstCol () const noexcept
 Return the 1-based column of the top-left cell (LazyRange only; 0 for other types).
uint32_t lastRow () const noexcept
 Bottom-right row for LazyRange (0 otherwise).
uint16_t lastCol () const noexcept
 Bottom-right column for LazyRange (0 otherwise).
const std::string & sheetName () const noexcept
bool empty () const
size_t size () const
XLCellValue at (size_t row, size_t col) const
 0-based (row, col) access. Works for Scalar, Array, and LazyRange.
XLCellValue operator[] (size_t index) const
XLFormulaArg materialize () const
 Materialize any arg into a dense row-major Array (copy).
XLCellValue asScalar () const
 Implicit-intersection / top-left scalar projection.
Iterator begin () const
Iterator end () const

Detailed Description

Lightweight formula evaluation engine.

Usage:

XLWorksheetEvaluationContext ctx(worksheet); // sheet-read port
auto resolver = XLFormulaEngine::makeResolver(ctx);
XLCellValue result = engine.evaluate("SUM(A1:C1)", resolver);
Class encapsulating a cell value.
Definition XLCellValue.hpp:89
Definition XLFormulaEngine.hpp:784
static XLCellResolver makeResolver(const XLEvaluationContext &context)
Create a CellResolver that reads live values from an evaluation context.
Definition XLFormulaEngine.cpp:988
XLCellValue evaluate(std::string_view formula, const XLCellResolver &resolver={}, XLFormulaDiagnosticReporter *reporter=nullptr) const
Evaluate a formula string.
Definition XLFormulaEngine.cpp:699
Evaluation context backed by a live worksheet (and its workbook for sheet-qualified refs).
Definition XLEvaluationContext.hpp:75

The engine is thread-safe for concurrent evaluate() calls after construction (the function table is built once in the constructor and is read-only thereafter). Cell lookup goes through XLEvaluationContext / XLCellResolver so formula code never depends on concrete worksheet internals.

Member Enumeration Documentation

◆ Type

enum class OpenXLSX::XLFormulaArg::Type
strong
Enumerator
Empty 
Scalar 
Array 
LazyRange 

Constructor & Destructor Documentation

◆ XLFormulaArg() [1/5]

OpenXLSX::XLFormulaArg::XLFormulaArg ( )
default

◆ XLFormulaArg() [2/5]

OpenXLSX::XLFormulaArg::XLFormulaArg ( XLCellValue v)
inline

◆ XLFormulaArg() [3/5]

OpenXLSX::XLFormulaArg::XLFormulaArg ( std::vector< XLCellValue > arr)
inline

Construct a column vector (N×1) from a flat list.

Preserves historical 1-D behaviour used by arithmetic broadcast helpers.

◆ XLFormulaArg() [4/5]

OpenXLSX::XLFormulaArg::XLFormulaArg ( std::vector< XLCellValue > data,
size_t rows,
size_t cols )
inline

Construct a dense row-major 2-D array.

Parameters
dataMust contain rows*cols elements (row-major).

◆ XLFormulaArg() [5/5]

OpenXLSX::XLFormulaArg::XLFormulaArg ( uint32_t r1,
uint32_t r2,
uint16_t c1,
uint16_t c2,
std::string sheetName,
const std::function< XLCellValue(std::string_view)> * resolver )
inline

Member Function Documentation

◆ asScalar()

XLCellValue OpenXLSX::XLFormulaArg::asScalar ( ) const
inlinenodiscard

Implicit-intersection / top-left scalar projection.

◆ at()

XLCellValue OpenXLSX::XLFormulaArg::at ( size_t row,
size_t col ) const
inlinenodiscard

0-based (row, col) access. Works for Scalar, Array, and LazyRange.

◆ begin()

Iterator OpenXLSX::XLFormulaArg::begin ( ) const
inline

◆ cols()

size_t OpenXLSX::XLFormulaArg::cols ( ) const
inline

◆ empty()

bool OpenXLSX::XLFormulaArg::empty ( ) const
inline

◆ end()

Iterator OpenXLSX::XLFormulaArg::end ( ) const
inline

◆ firstCol()

uint16_t OpenXLSX::XLFormulaArg::firstCol ( ) const
inlinenoexcept

Return the 1-based column of the top-left cell (LazyRange only; 0 for other types).

◆ firstRow()

uint32_t OpenXLSX::XLFormulaArg::firstRow ( ) const
inlinenoexcept

Return the 1-based row of the top-left cell (LazyRange only; 0 for other types).

◆ lastCol()

uint16_t OpenXLSX::XLFormulaArg::lastCol ( ) const
inlinenoexcept

Bottom-right column for LazyRange (0 otherwise).

◆ lastRow()

uint32_t OpenXLSX::XLFormulaArg::lastRow ( ) const
inlinenoexcept

Bottom-right row for LazyRange (0 otherwise).

◆ materialize()

XLFormulaArg OpenXLSX::XLFormulaArg::materialize ( ) const
inlinenodiscard

Materialize any arg into a dense row-major Array (copy).

Scalars become 1×1; LazyRange is fully resolved via the cell resolver.

◆ operator[]()

XLCellValue OpenXLSX::XLFormulaArg::operator[] ( size_t index) const
inline

◆ rows()

size_t OpenXLSX::XLFormulaArg::rows ( ) const
inline

◆ sheetName()

const std::string & OpenXLSX::XLFormulaArg::sheetName ( ) const
inlinenodiscardnoexcept

◆ size()

size_t OpenXLSX::XLFormulaArg::size ( ) const
inline

◆ type()

Type OpenXLSX::XLFormulaArg::type ( ) const
inline

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