diff --git a/include/xlnt/worksheet/sheet_view.hpp b/include/xlnt/worksheet/sheet_view.hpp index 23f4d6ac..2c04bd9a 100644 --- a/include/xlnt/worksheet/sheet_view.hpp +++ b/include/xlnt/worksheet/sheet_view.hpp @@ -192,6 +192,30 @@ public: return type_; } + /// + /// has a top left cell? + /// + bool has_top_left_cell() const + { + return top_left_cell_.is_set(); + } + + /// + /// Sets the top left cell of this view. + /// + void top_left_cell(const cell_reference& ref) + { + top_left_cell_.set(ref); + } + + /// + /// Returns the top left cell of this view. + /// + cell_reference top_left_cell() const + { + return top_left_cell_.get(); + } + /// /// Returns true if this view is equal to rhs based on its id, grid lines setting, /// default grid color, pane, and selections. @@ -202,7 +226,8 @@ public: && show_grid_lines_ == rhs.show_grid_lines_ && default_grid_color_ == rhs.default_grid_color_ && pane_ == rhs.pane_ - && selections_ == rhs.selections_; + && selections_ == rhs.selections_ + && top_left_cell_ == rhs.top_left_cell_; } private: @@ -231,6 +256,11 @@ private: /// optional pane_; + /// + /// The top left cell + /// + optional top_left_cell_; + /// /// The collection of selections /// diff --git a/source/detail/serialization/xlsx_consumer.cpp b/source/detail/serialization/xlsx_consumer.cpp index 9b36b6c1..19a4c1ad 100644 --- a/source/detail/serialization/xlsx_consumer.cpp +++ b/source/detail/serialization/xlsx_consumer.cpp @@ -465,6 +465,10 @@ std::string xlsx_consumer::read_worksheet_begin(const std::string &rel_id) { new_view.show_grid_lines(is_true(parser().attribute("showGridLines"))); } + if (parser().attribute_present("topLeftCell")) + { + new_view.top_left_cell(cell_reference(parser().attribute("topLeftCell"))); + } if (parser().attribute_present("defaultGridColor")) // default="true" { diff --git a/source/detail/serialization/xlsx_producer.cpp b/source/detail/serialization/xlsx_producer.cpp index f7a4f298..b435bd9d 100644 --- a/source/detail/serialization/xlsx_producer.cpp +++ b/source/detail/serialization/xlsx_producer.cpp @@ -2298,13 +2298,17 @@ void xlsx_producer::write_worksheet(const relationship &rel) write_attribute("tabSelected", write_bool(true)); } - write_attribute("workbookViewId", view.id()); - if (view.type() != sheet_view_type::normal) { write_attribute("view", view.type() == sheet_view_type::page_break_preview ? "pageBreakPreview" : "pageLayout"); } + if (view.has_top_left_cell()) + { + write_attribute("topLeftCell", view.top_left_cell().to_string()); + } + + write_attribute("workbookViewId", view.id()); if (view.has_pane()) {