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

The XLFormula class encapsulates the concept of an Excel formula. The class is essentially a wrapper around a std::string. More...

#include <XLFormula.hpp>

Public Member Functions

 XLFormula ()
 Constructor.
 
template<typename T , typename = std::enable_if_t<std::is_same_v<std::decay_t<T>, std::string> or std::is_same_v<std::decay_t<T>, std::string_view> || std::is_same_v<std::decay_t<T>, const char*> or std::is_same_v<std::decay_t<T>, char*>>>
 XLFormula (T formula)
 Constructor, taking a string-type argument.
 
 XLFormula (const XLFormula &other)
 Copy constructor.
 
 XLFormula (XLFormula &&other) noexcept
 Move constructor.
 
 ~XLFormula ()
 Destructor.
 
XLFormulaoperator= (const XLFormula &other)
 Copy assignment operator.
 
XLFormulaoperator= (XLFormula &&other) noexcept
 Move assignment operator.
 
template<typename T , typename = std::enable_if_t<std::is_same_v<std::decay_t<T>, std::string> or std::is_same_v<std::decay_t<T>, std::string_view> || std::is_same_v<std::decay_t<T>, const char*> or std::is_same_v<std::decay_t<T>, char*>>>
XLFormulaoperator= (T formula)
 Templated assignment operator, taking a string-type object as an argument.
 
template<typename T , typename = std::enable_if_t<std::is_same_v<std::decay_t<T>, std::string> or std::is_same_v<std::decay_t<T>, std::string_view> || std::is_same_v<std::decay_t<T>, const char*> or std::is_same_v<std::decay_t<T>, char*>>>
void set (T formula)
 Templated setter function, taking a string-type object as an argument.
 
std::string get () const
 Get the formula as a std::string.
 
 operator std::string () const
 Conversion operator, for converting object to a std::string.
 
XLFormulaclear ()
 Clear the formula.
 

Friends

bool operator== (const XLFormula &lhs, const XLFormula &rhs)
 
bool operator!= (const XLFormula &lhs, const XLFormula &rhs)
 
std::ostream & operator<< (std::ostream &os, const XLFormula &value)
 send a formula string to an ostream
 

Detailed Description

The XLFormula class encapsulates the concept of an Excel formula. The class is essentially a wrapper around a std::string.

Warning
This class currently only supports simple formulas. Array formulas and shared formulas are not supported. Unfortunately, many spreadsheets have shared formulas, so this class is probably best used for adding formulas, not reading them from an existing spreadsheet.
Todo:
Enable handling of shared and array formulas.

Constructor & Destructor Documentation

◆ XLFormula() [1/4]

XLFormula::XLFormula ( )
default

Constructor.

Constructor. Default implementation.

◆ XLFormula() [2/4]

template<typename T , typename = std::enable_if_t<std::is_same_v<std::decay_t<T>, std::string> or std::is_same_v<std::decay_t<T>, std::string_view> || std::is_same_v<std::decay_t<T>, const char*> or std::is_same_v<std::decay_t<T>, char*>>>
OpenXLSX::XLFormula::XLFormula ( formula)
inlineexplicit

Constructor, taking a string-type argument.

Template Parameters
TType of argument used. Must be string-type.
Parameters
formulaThe formula to initialize the object with.

◆ XLFormula() [3/4]

XLFormula::XLFormula ( const XLFormula other)
default

Copy constructor.

Parameters
otherObject to be copied.

Copy constructor. Default implementation.

◆ XLFormula() [4/4]

XLFormula::XLFormula ( XLFormula &&  other)
defaultnoexcept

Move constructor.

Parameters
otherObject to be moved.

Move constructor. Default implementation.

◆ ~XLFormula()

XLFormula::~XLFormula ( )
default

Destructor.

Destructor. Default implementation.

Member Function Documentation

◆ clear()

XLFormula & XLFormula::clear ( )

Clear the formula.

Returns
Return a reference to the cleared object.

Set the m_formulaString member to an empty string.

◆ get()

std::string XLFormula::get ( ) const

Get the formula as a std::string.

Returns
A std::string with the formula.

Return the m_formulaString member variable.

◆ operator std::string()

XLFormula::operator std::string ( ) const

Conversion operator, for converting object to a std::string.

Returns
The formula as a std::string.

◆ operator=() [1/3]

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

Copy assignment operator.

Parameters
otherObject to be copied.
Returns
Reference to copied-to object.

Copy assignment operator. Default implementation.

◆ operator=() [2/3]

template<typename T , typename = std::enable_if_t<std::is_same_v<std::decay_t<T>, std::string> or std::is_same_v<std::decay_t<T>, std::string_view> || std::is_same_v<std::decay_t<T>, const char*> or std::is_same_v<std::decay_t<T>, char*>>>
XLFormula & OpenXLSX::XLFormula::operator= ( formula)
inline

Templated assignment operator, taking a string-type object as an argument.

Template Parameters
TType of argument (only string-types are allowed).
Parameters
formulaString containing the formula.
Returns
Reference to the assigned-to object.

◆ operator=() [3/3]

XLFormula & XLFormula::operator= ( XLFormula &&  other)
defaultnoexcept

Move assignment operator.

Parameters
otherObject to be moved.
Returns
Reference to moved-to object.

Move assignment operator. Default implementation.

◆ set()

template<typename T , typename = std::enable_if_t<std::is_same_v<std::decay_t<T>, std::string> or std::is_same_v<std::decay_t<T>, std::string_view> || std::is_same_v<std::decay_t<T>, const char*> or std::is_same_v<std::decay_t<T>, char*>>>
void OpenXLSX::XLFormula::set ( formula)
inline

Templated setter function, taking a string-type object as an argument.

Template Parameters
TType of argument (only string-types are allowed).
Parameters
formulaString containing the formula.

Friends And Related Symbol Documentation

◆ operator!=

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

◆ operator<<

std::ostream & operator<< ( std::ostream &  os,
const XLFormula value 
)
friend

send a formula string to an ostream

Parameters
osthe output destination
valuethe formula to send to os
Returns

◆ operator==

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

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