Cell Access

Examples

You can obtain a cell_access instance either from model_context or document class.

Here is an example of how to obtain it from a model_context instance:

ixion::model_context cxt;
cxt.append_sheet("Sheet");

// fill this model context

ixion::abs_address_t A1(0, 0, 0);
ixion::cell_access ca = cxt.get_cell_access(A1);

Here is an example of how to obtain it from a document instance:

ixion::document doc;
doc.append_sheet("Sheet");

// fill this document

ixion::cell_access ca = doc.get_cell_access("A1");

Once you have your cell_access instance, you can, for instance, print the value of the cell as follows:

switch (ca.get_value_type())
{
    case ixion::cell_value_t::numeric:
    {
        double v = ca.get_numeric_value();
        cout << "numeric value: " << v << endl;
        break;
    }
    case ixion::cell_value_t::string:
    {
        std::string_view s = ca.get_string_value();
        cout << "string value: " << s << endl;
        break;
    }
    case ixion::cell_value_t::boolean:
    {
        cout << "boolean value: " << ca.get_boolean_value() << endl;
        break;
    }
    case ixion::cell_value_t::error:
    {
        ixion::formula_error_t err = ca.get_error_value();
        cout << "error value: " << ixion::get_formula_error_name(err) << endl;
        break;
    }
    case ixion::cell_value_t::empty:
    {
        cout << "empty cell" << endl;
        break;
    }
    default:
        cout << "???" << endl;
}

The complete source code of this example is avaiable here.

API Reference

class cell_access

This class provides a read-only access to a single cell. It’s more efficient to use this class if you need to make multiple successive queries to the same cell.

Note that an instance of this class will get invalidated when the content of ixion::model_context is modified.

Public Functions

cell_access(cell_access &&other)
cell_access &operator=(cell_access &&other)
~cell_access()
celltype_t get_type() const
cell_value_t get_value_type() const
const formula_cell *get_formula_cell() const
formula_result get_formula_result() const
double get_numeric_value() const
bool get_boolean_value() const
std::string_view get_string_value() const
string_id_t get_string_identifier() const
formula_error_t get_error_value() const