File: cell_access.cpp

package info (click to toggle)
libixion 0.20.0-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,472 kB
  • sloc: cpp: 21,273; sh: 4,561; makefile: 463; python: 297
file content (81 lines) | stat: -rw-r--r-- 1,958 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <iostream>
#include <ixion/document.hpp>
#include <ixion/model_context.hpp>
#include <ixion/cell_access.hpp>
#include <ixion/address.hpp>

void access(const ixion::cell_access& ca)
{
    //!code-start: get-value
    switch (ca.get_value_type())
    {
        case ixion::cell_value_t::numeric:
        {
            double v = ca.get_numeric_value();
            std::cout << "numeric value: " << v << std::endl;
            break;
        }
        case ixion::cell_value_t::string:
        {
            std::string_view s = ca.get_string_value();
            std::cout << "string value: " << s << std::endl;
            break;
        }
        case ixion::cell_value_t::boolean:
        {
            std::cout << "boolean value: " << ca.get_boolean_value() << std::endl;
            break;
        }
        case ixion::cell_value_t::error:
        {
            ixion::formula_error_t err = ca.get_error_value();
            std::cout << "error value: " << ixion::get_formula_error_name(err) << std::endl;
            break;
        }
        case ixion::cell_value_t::empty:
        {
            std::cout << "empty cell" << std::endl;
            break;
        }
        default:
            std::cout << "???" << std::endl;
    }
    //!code-end: get-value
}

void from_document()
{
    //!code-start: get-from-document
    ixion::document doc;
    doc.append_sheet("Sheet");

    // fill this document

    ixion::cell_access ca = doc.get_cell_access("A1");
    //!code-end: get-from-document

    access(ca);
}

void from_model_context()
{
    //!code-start: get-from-model-context
    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);
    //!code-end: get-from-model-context

    access(ca);
}

int main(int argc, char** argv)
{
    from_document();
    from_model_context();

    return EXIT_SUCCESS;
}