cell_reference cell_reference::make_offset(int column_offset, int row_offset) const { // TODO: check for overflow/underflow auto relative_column = static_cast<column_t::index_t>(static_cast<int>(column_.index) + column_offset); auto relative_row = static_cast<row_t>(static_cast<int>(row_) + row_offset); return cell_reference(relative_column, relative_row); }
void worksheet::append(const std::unordered_map<int, std::string> &cells) { auto row = get_next_row(); for (auto cell : cells) { get_cell(cell_reference(static_cast<column_t>(cell.first), row)).set_value(cell.second); } }
void worksheet::append(const std::unordered_map<std::string, std::string> &cells) { auto row = get_next_row(); for (auto cell : cells) { get_cell(cell_reference(cell.first, row)).set_value(cell.second); } }
void worksheet::freeze_panes(const cell_reference &ref) { if (ref == "A1") { unfreeze_panes(); return; } if (!has_view()) { d_->views_.push_back(sheet_view()); } auto &primary_view = d_->views_.front(); if (!primary_view.has_pane()) { primary_view.pane(pane()); } primary_view.pane().top_left_cell = ref; primary_view.pane().state = pane_state::frozen; primary_view.clear_selections(); if (ref.column() == "A") // no column is frozen { primary_view.add_selection(selection(pane_corner::bottom_left, ref)); primary_view.pane().active_pane = pane_corner::bottom_left; primary_view.pane().y_split = ref.row() - 1; } else if (ref.row() == 1) // no row is frozen { primary_view.add_selection(selection(pane_corner::top_right, ref)); primary_view.pane().active_pane = pane_corner::top_right; primary_view.pane().x_split = ref.column_index() - 1; } else // column and row is frozen { primary_view.add_selection(selection(pane_corner::top_right, cell_reference(ref.column(), 1))); primary_view.add_selection(selection(pane_corner::bottom_left, cell_reference(1, ref.row()))); primary_view.add_selection(selection(pane_corner::bottom_right, ref)); primary_view.pane().active_pane = pane_corner::bottom_right; primary_view.pane().x_split = ref.column_index() - 1; primary_view.pane().y_split = ref.row() - 1; } }
cell_reference::cell_reference(const std::string &string) { bool absolute = false; auto split = split_reference(string, absolute, absolute); *this = cell_reference(split.first, split.second, absolute); }
cell_reference cell_reference::make_offset(int column_offset, int row_offset) const { return cell_reference(column_index_ + column_offset, row_index_ + row_offset); }
bool worksheet::has_frozen_panes() const { return get_frozen_panes() != cell_reference("A1"); }
void worksheet::append() { get_cell(cell_reference(1, get_next_row())); }
void worksheet::unfreeze_panes() { d_->freeze_panes_ = cell_reference("A1"); }
void worksheet::freeze_panes(const std::string &top_left_coordinate) { d_->freeze_panes_ = cell_reference(top_left_coordinate); }
const cell worksheet::cell(xlnt::column_t column, row_t row) const { return cell(cell_reference(column, row)); }
cell_reference cell_reference::make_offset(int column_offset, int row_offset) const { //TODO: check for overflow/underflow return cell_reference(static_cast<column_t>(static_cast<int>(column_.index) + column_offset), static_cast<row_t>(static_cast<int>(row_) + row_offset)); }
bool cell_reference::operator!=(const std::string &reference_string) const { return *this != cell_reference(reference_string); }
cell cell::offset(int column, int row) { return get_parent().get_cell(cell_reference(d_->column_ + column, d_->row_ + row)); }