re-save custom_heights_widths.xlsx, add defaultColWidth sheet attribute

-- custom_heights was the only test sheet where the integral value was being saved with a trailing ".0"
-- Updated tests to expect the new values
-- added the new property "defaultColWidth"
This commit is contained in:
Crzyrndm 2018-06-24 11:53:45 +12:00
parent 884558fd15
commit 7820ac548f
5 changed files with 21 additions and 11 deletions

View File

@ -44,6 +44,11 @@ public:
/// </summary>
optional<double> default_row_height;
/// <summary>
/// The default column width
/// </summary>
optional<double> default_column_width;
/// <summary>
/// x14ac extension, dyDescent property
/// </summary>

View File

@ -544,7 +544,11 @@ std::string xlsx_consumer::read_worksheet_begin(const std::string &rel_id)
ws.d_->format_properties_.base_col_width =
parser().attribute<double>("baseColWidth");
}
if (parser().attribute_present("defaultColWidth"))
{
ws.d_->format_properties_.default_column_width =
parser().attribute<double>("defaultColWidth");
}
if (parser().attribute_present("defaultRowHeight"))
{
ws.d_->format_properties_.default_row_height =

View File

@ -2332,7 +2332,11 @@ void xlsx_producer::write_worksheet(const relationship &rel)
write_attribute("baseColWidth",
format_properties.base_col_width.get());
}
if (format_properties.default_column_width.is_set())
{
write_attribute("defaultColWidth",
format_properties.default_column_width.get());
}
if (format_properties.default_row_height.is_set())
{
write_attribute("defaultRowHeight",

View File

@ -474,11 +474,11 @@ public:
xlnt_assert_equals(ws.cell("B4").value<std::string>(), "B4");
xlnt_assert_equals(ws.cell("D4").value<std::string>(), "D4");
xlnt_assert_equals(ws.row_properties(1).height.get(), 100);
xlnt_assert_equals(ws.row_properties(1).height.get(), 99.95);
xlnt_assert(!ws.row_properties(2).height.is_set());
xlnt_assert_equals(ws.row_properties(3).height.get(), 100);
xlnt_assert_equals(ws.row_properties(3).height.get(), 99.95);
xlnt_assert(!ws.row_properties(4).height.is_set());
xlnt_assert_equals(ws.row_properties(5).height.get(), 100);
xlnt_assert_equals(ws.row_properties(5).height.get(), 99.95);
auto width = ((16.0 * 7) - 5) / 7;
@ -523,13 +523,13 @@ public:
ws.row_properties(i).dy_descent = 0.2;
}
ws.row_properties(1).height = 100;
ws.row_properties(1).height = 99.95;
ws.row_properties(1).custom_height = true;
ws.row_properties(3).height = 100;
ws.row_properties(3).height = 99.95;
ws.row_properties(3).custom_height = true;
ws.row_properties(5).height = 100;
ws.row_properties(5).height = 99.95;
ws.row_properties(5).custom_height = true;
auto width = ((16.0 * 7) - 5) / 7;
@ -543,9 +543,6 @@ public:
ws.column_properties("E").width = width;
ws.column_properties("E").custom_width = true;
wb.default_slicer_style("SlicerStyleLight1");
wb.enable_known_fonts();
xlnt_assert(workbook_matches_file(wb,
path_helper::test_file("13_custom_heights_widths.xlsx")));
}