Add serialisation of "topLeftCell" sheetView attribute

This commit is contained in:
Crzyrndm 2018-06-24 14:19:03 +12:00
parent d2d0c2ab55
commit e8fcd49c0d
3 changed files with 41 additions and 3 deletions

View File

@ -192,6 +192,30 @@ public:
return type_;
}
/// <summary>
/// has a top left cell?
/// </summary>
bool has_top_left_cell() const
{
return top_left_cell_.is_set();
}
/// <summary>
/// Sets the top left cell of this view.
/// </summary>
void top_left_cell(const cell_reference& ref)
{
top_left_cell_.set(ref);
}
/// <summary>
/// Returns the top left cell of this view.
/// </summary>
cell_reference top_left_cell() const
{
return top_left_cell_.get();
}
/// <summary>
/// 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:
/// </summary>
optional<xlnt::pane> pane_;
/// <summary>
/// The top left cell
/// </summary>
optional<cell_reference> top_left_cell_;
/// <summary>
/// The collection of selections
/// </summary>

View File

@ -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"
{

View File

@ -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())
{