Spreadsheet Document
Document
-
class orcus::spreadsheet::document : public orcus::iface::document_dumper
Internal document representation used only for testing the filters. It uses ixion’s model_context implementation to store raw cell values.
Public Functions
-
document(const range_size_t &sheet_size)
-
~document()
-
styles &get_styles()
-
const styles &get_styles() const
-
pivot_collection &get_pivot_collection()
-
const pivot_collection &get_pivot_collection() const
-
void clear()
Clear document content, to make it empty.
-
void recalc_formula_cells()
Calculate those formula cells that have been newly inserted and have not yet been calculated.
-
virtual void dump(dump_format_t format, const std::string &output) const override
-
void dump_flat(const std::string &outdir) const
Dump document content to specified output directory in flat format.
- Parameters
outdir – path to the output directory.
-
void dump_html(const ::std::string &outdir) const
Dump document content to specified output directory in html format.
- Parameters
outdir – path to the output directory.
-
void dump_json(const ::std::string &outdir) const
Dump document content to specified output directory in json format.
- Parameters
outdir – path to the output directory.
-
void dump_csv(const std::string &outdir) const
Dump document content to specified output directory in csv format.
- Parameters
outdir – path to the output directory.
-
virtual void dump_check(std::ostream &os) const override
Dump document content to stdout in the special format used for content verification during unit test.
-
sheet_t get_sheet_index(std::string_view name) const
-
std::string_view get_sheet_name(sheet_t sheet_pos) const
-
range_size_t get_sheet_size() const
-
void set_sheet_size(const range_size_t &sheet_size)
-
size_t get_sheet_count() const
-
void set_origin_date(int year, int month, int day)
-
date_time_t get_origin_date() const
-
void set_formula_grammar(formula_grammar_t grammar)
-
formula_grammar_t get_formula_grammar() const
-
const ixion::formula_name_resolver *get_formula_name_resolver(formula_ref_context_t cxt) const
-
ixion::model_context &get_model_context()
-
const ixion::model_context &get_model_context() const
-
const document_config &get_config() const
-
void set_config(const document_config &cfg)
-
string_pool &get_string_pool()
-
void insert_table(table_t *p)
Insert a new table object into the document. The document will take ownership of the inserted object after the call. The object will get inserted only when there is no pre-existing table object of the same name. The object not being inserted will be deleted.
- Parameters
p – table object to insert.
-
const table_t *get_table(std::string_view name) const
-
void finalize()
-
document(const range_size_t &sheet_size)
Sheet
-
class orcus::spreadsheet::sheet
This class represents a single sheet instance in the internal document model.
Public Functions
-
virtual ~sheet()
-
void set_auto(row_t row, col_t col, std::string_view s)
-
void set_string(row_t row, col_t col, string_id_t sindex)
-
void set_value(row_t row, col_t col, double value)
-
void set_bool(row_t row, col_t col, bool value)
-
void set_date_time(row_t row, col_t col, int year, int month, int day, int hour, int minute, double second)
-
void set_format(row_t row, col_t col, size_t index)
-
void set_format(row_t row_start, col_t col_start, row_t row_end, col_t col_end, size_t index)
-
void set_formula(row_t row, col_t col, const ixion::formula_tokens_store_ptr_t &tokens)
-
void set_formula(row_t row, col_t col, const ixion::formula_tokens_store_ptr_t &tokens, ixion::formula_result result)
-
void set_grouped_formula(const range_t &range, ixion::formula_tokens_t tokens)
-
void set_grouped_formula(const range_t &range, ixion::formula_tokens_t tokens, ixion::formula_result result)
-
void set_col_width(col_t col, col_width_t width)
-
col_width_t get_col_width(col_t col, col_t *col_start, col_t *col_end) const
-
void set_row_height(row_t row, row_height_t height)
-
row_height_t get_row_height(row_t row, row_t *row_start, row_t *row_end) const
-
void set_merge_cell_range(const range_t &range)
-
void fill_down_cells(row_t src_row, col_t src_col, row_t range_size)
-
range_t get_merge_cell_range(row_t row, col_t col) const
Return the size of a merged cell range.
- Parameters
row – row position of the upper-left cell.
col – column position of the upper-left cell.
- Returns
merged cell range.
-
size_t get_string_identifier(row_t row, col_t col) const
-
auto_filter_t *get_auto_filter_data()
-
const auto_filter_t *get_auto_filter_data() const
-
void set_auto_filter_data(auto_filter_t *p)
-
ixion::abs_range_t get_data_range() const
Return the smallest range that contains all non-empty cells in this sheet. The top-left corner of the returned range is always column 0 and row 0.
- Returns
smallest range that contains all non-empty cells.
-
sheet_t get_index() const
-
date_time_t get_date_time(row_t row, col_t col) const
-
void finalize()
-
void dump_flat(std::ostream &os) const
-
void dump_check(std::ostream &os, std::string_view sheet_name) const
-
void dump_html(std::ostream &os) const
-
void dump_json(std::ostream &os) const
-
void dump_csv(std::ostream &os) const
-
size_t get_cell_format(row_t row, col_t col) const
Get the cell format ID of specified cell.
-
virtual ~sheet()
Pivot Table
-
struct orcus::spreadsheet::pivot_cache_record_value_t
Public Types
-
enum class record_type
Values:
-
enumerator unknown
-
enumerator boolean
-
enumerator date_time
-
enumerator character
-
enumerator numeric
-
enumerator blank
-
enumerator error
-
enumerator unknown
-
using value_type = std::variant<bool, double, std::size_t, std::string_view, date_time_t>
Public Functions
-
pivot_cache_record_value_t()
-
pivot_cache_record_value_t(std::string_view s)
-
pivot_cache_record_value_t(double v)
-
pivot_cache_record_value_t(size_t index)
-
bool operator==(const pivot_cache_record_value_t &other) const
-
bool operator!=(const pivot_cache_record_value_t &other) const
-
enum class record_type
-
struct orcus::spreadsheet::pivot_cache_item_t
Public Types
-
enum class item_type
Values:
-
enumerator unknown
-
enumerator boolean
-
enumerator date_time
-
enumerator character
-
enumerator numeric
-
enumerator blank
-
enumerator error
-
enumerator unknown
-
using value_type = std::variant<bool, double, std::string_view, date_time_t, error_value_t>
Public Functions
-
pivot_cache_item_t()
-
pivot_cache_item_t(std::string_view s)
-
pivot_cache_item_t(double numeric)
-
pivot_cache_item_t(bool boolean)
-
pivot_cache_item_t(const date_time_t &date_time)
-
pivot_cache_item_t(error_value_t error)
-
pivot_cache_item_t(const pivot_cache_item_t &other)
-
pivot_cache_item_t(pivot_cache_item_t &&other)
-
bool operator<(const pivot_cache_item_t &other) const
-
bool operator==(const pivot_cache_item_t &other) const
-
pivot_cache_item_t &operator=(pivot_cache_item_t other)
-
void swap(pivot_cache_item_t &other)
-
enum class item_type
-
struct orcus::spreadsheet::pivot_cache_group_data_t
Group data for a pivot cache field.
Public Functions
-
pivot_cache_group_data_t(size_t _base_field)
-
pivot_cache_group_data_t(const pivot_cache_group_data_t &other)
-
pivot_cache_group_data_t(pivot_cache_group_data_t &&other)
-
pivot_cache_group_data_t() = delete
Public Members
-
pivot_cache_indices_t base_to_group_indices
Mapping of base field member indices to the group field item indices.
-
std::optional<range_grouping_type> range_grouping
-
pivot_cache_items_t items
Individual items comprising the group.
-
size_t base_field
0-based index of the base field.
-
struct range_grouping_type
Public Functions
-
range_grouping_type() = default
-
range_grouping_type(const range_grouping_type &other) = default
Public Members
-
pivot_cache_group_by_t group_by = pivot_cache_group_by_t::range
-
bool auto_start = true
-
bool auto_end = true
-
double start = 0.0
-
double end = 0.0
-
double interval = 1.0
-
date_time_t start_date
-
date_time_t end_date
-
range_grouping_type() = default
-
pivot_cache_group_data_t(size_t _base_field)
-
struct orcus::spreadsheet::pivot_cache_field_t
Public Functions
-
pivot_cache_field_t()
-
pivot_cache_field_t(std::string_view _name)
-
pivot_cache_field_t(const pivot_cache_field_t &other)
-
pivot_cache_field_t(pivot_cache_field_t &&other)
Public Members
-
std::string_view name
Field name. It must be interned with the string pool belonging to the document.
-
pivot_cache_items_t items
-
std::optional<double> min_value
-
std::optional<double> max_value
-
std::optional<date_time_t> min_date
-
std::optional<date_time_t> max_date
-
std::unique_ptr<pivot_cache_group_data_t> group_data
-
pivot_cache_field_t()
-
class orcus::spreadsheet::pivot_cache
Public Types
-
using fields_type = std::vector<pivot_cache_field_t>
-
using records_type = std::vector<pivot_cache_record_t>
Public Functions
-
pivot_cache(pivot_cache_id_t cache_id, string_pool &sp)
-
~pivot_cache()
-
void insert_fields(fields_type fields)
Bulk-insert all the fields in one step. Note that this will replace any pre-existing fields if any.
- Parameters
fields – field instances to move into storage.
-
void insert_records(records_type record)
-
size_t get_field_count() const
-
const pivot_cache_field_t *get_field(size_t index) const
Retrieve a field data by its index.
- Parameters
index – index of the field to retrieve.
- Returns
pointer to the field instance, or nullptr if the index is out-of-range.
-
pivot_cache_id_t get_id() const
-
const records_type &get_all_records() const
-
using fields_type = std::vector<pivot_cache_field_t>
-
class orcus::spreadsheet::pivot_collection
Public Functions
-
~pivot_collection()
-
void insert_worksheet_cache(std::string_view sheet_name, const ixion::abs_range_t &range, std::unique_ptr<pivot_cache> &&cache)
Insert a new pivot cache associated with a worksheet source.
- Parameters
sheet_name – name of the sheet where the source data is.
range – range of the source data. Note that the sheet indices are not used.
cache – pivot cache instance to store.
-
void insert_worksheet_cache(std::string_view table_name, std::unique_ptr<pivot_cache> &&cache)
Insert a new pivot cache associated with a table name.
- Parameters
table_name – source table name.
cache – pivot cache instance to store.
-
size_t get_cache_count() const
Count the number of pivot caches currently stored.
- Returns
number of pivot caches currently stored in the document.
-
const pivot_cache *get_cache(std::string_view sheet_name, const ixion::abs_range_t &range) const
-
pivot_cache *get_cache(pivot_cache_id_t cache_id)
-
const pivot_cache *get_cache(pivot_cache_id_t cache_id) const
-
~pivot_collection()
Import Factory
-
class orcus::spreadsheet::import_factory : public orcus::spreadsheet::iface::import_factory
Public Functions
-
virtual ~import_factory()
-
virtual iface::import_global_settings *get_global_settings() override
- Returns
pointer to the shared strings instance. It may return NULL if the client app doesn’t support shared strings.
-
virtual iface::import_styles *get_styles() override
- Returns
pointer to the styles instance. It may return NULL if the client app doesn’t support styles.
-
virtual iface::import_named_expression *get_named_expression() override
-
virtual iface::import_reference_resolver *get_reference_resolver(formula_ref_context_t cxt) override
-
virtual iface::import_pivot_cache_definition *create_pivot_cache_definition(orcus::spreadsheet::pivot_cache_id_t cache_id) override
Create an interface for pivot cache definition import for a specified cache ID. In case a pivot cache alrady exists for the passed ID, the client app should overwrite the existing cache with a brand-new cache instance.
- Parameters
cache_id – numeric ID associated with the pivot cache.
- Returns
pointer to the pivot cache interface instance. If may return NULL if the client app doesn’t support pivot tables.
-
virtual iface::import_pivot_cache_records *create_pivot_cache_records(orcus::spreadsheet::pivot_cache_id_t cache_id) override
Create an interface for pivot cache records import for a specified cache ID.
- Parameters
cache_id – numeric ID associated with the pivot cache.
- Returns
pointer to the pivot cache records interface instance. If may return nullptr if the client app doesn’t support pivot tables.
-
virtual iface::import_sheet *append_sheet(sheet_t sheet_index, std::string_view name) override
Append a sheet with specified sheet position index and name.
- Parameters
sheet_index – position index of the sheet to be appended. It is 0-based i.e. the first sheet to be appended will have an index value of 0.
name – sheet name.
- Returns
pointer to the sheet instance. It may return nullptr if the client app fails to append a new sheet.
-
virtual iface::import_sheet *get_sheet(std::string_view name) override
Get a sheet instance by name.
- Parameters
name – sheet name.
- Returns
pointer to the sheet instance whose name matches the name passed to this method. It returns nullptr if no sheet instance exists by the specified name.
-
virtual iface::import_sheet *get_sheet(sheet_t sheet_index) override
Retrieve sheet instance by specified numerical sheet index.
- Parameters
sheet_index – sheet index
- Returns
pointer to the sheet instance, or nullptr if no sheet instance exists at specified sheet index position.
-
virtual void finalize() override
This method is called at the end of import, to give the implementor a chance to perform post-processing if necessary.
-
void set_default_row_size(row_t row_size)
-
void set_default_column_size(col_t col_size)
-
void set_character_set(character_set_t charset)
-
character_set_t get_character_set() const
-
void set_recalc_formula_cells(bool b)
When setting this flag to true, those formula cells with no cached results will be re-calculated upon loading.
- Parameters
b – value of this flag.
-
void set_formula_error_policy(formula_error_policy_t policy)
-
virtual ~import_factory()