Orcus
Loading...
Searching...
No Matches
orcus::spreadsheet::iface::import_named_expression Class Referenceabstract

#include <import_interface.hpp>

Public Member Functions

virtual void set_base_position (const src_address_t &pos)=0
virtual void set_named_expression (std::string_view name, std::string_view expression)=0
virtual void set_named_range (std::string_view name, std::string_view range)=0
virtual void commit ()=0

Detailed Description

Interface for importing named expressions or ranges.

This interface has two different methods for defining named expressions:

Generally speaking, set_named_expression() can be used to define both named expression and named range. However, the implementor may choose to apply a different syntax rule to parse an expression passed to set_named_range(), depending on the formula grammar defined via import_global_settings::set_default_formula_grammar(). For instance, the OpenDocument Spreadsheet format is known to use different syntax rules between named expressions and named ranges.

A named range is a special case of a named expression where the expression consists of only one single cell range token.

Here is a code example of how a named expression is defined:

// set the A1 on the first sheet as its origin (optional).
src_address_t origin{0, 0, 0};
iface->set_base_position(origin);
iface->set_named_expression("MyExpression", "SUM(A1:B10)+SUM(D1:D4)");
iface->commit();
Definition import_interface.hpp:306
Definition types.hpp:718

Replace the above set_named_expression() call with set_named_range() if you wish to define a named range instead.

Member Function Documentation

◆ commit()

virtual void orcus::spreadsheet::iface::import_named_expression::commit ( )
pure virtual

Commit the named expression or range currently in the buffer to the document.

◆ set_base_position()

virtual void orcus::spreadsheet::iface::import_named_expression::set_base_position ( const src_address_t & pos)
pure virtual

Specify an optional base position, or origin, from which to evaluate a named expression. If not specified, the implementor should use the top-left corner cell on the first sheet as its origin.

Parameters
poscell position to be used as the origin.

◆ set_named_expression()

virtual void orcus::spreadsheet::iface::import_named_expression::set_named_expression ( std::string_view name,
std::string_view expression )
pure virtual

Set a named expression to the buffer.

Parameters
namename of the expression to be defined.
expressionexpression to be associated with the name.

◆ set_named_range()

virtual void orcus::spreadsheet::iface::import_named_expression::set_named_range ( std::string_view name,
std::string_view range )
pure virtual

Set a named range to the buffer.

Parameters
namename of the expression to be defined.
rangerange to be associated with the name.