From 7f08c77a90badb7f75323a56558ce11d49421974 Mon Sep 17 00:00:00 2001 From: Alexandros Naskos Date: Wed, 25 Oct 2017 15:04:51 +0300 Subject: [PATCH] Empty row properties are now written correctly. Setting a row's height now also causes customHeight to be emitted. --- source/detail/serialization/xlsx_producer.cpp | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/source/detail/serialization/xlsx_producer.cpp b/source/detail/serialization/xlsx_producer.cpp index 9904274b..54e57387 100644 --- a/source/detail/serialization/xlsx_producer.cpp +++ b/source/detail/serialization/xlsx_producer.cpp @@ -2175,8 +2175,14 @@ void xlsx_producer::write_worksheet(const relationship &rel) write_start_element(xmlns, "sheetData"); - for (auto row : ws.rows()) + for (auto row : ws.rows(false)) { + auto row_index = row.front().row(); + + write_start_element(xmlns, "row"); + + write_attribute("r", row_index); + auto min = static_cast(row.length()); xlnt::row_t max = 0; bool any_non_null = false; @@ -2192,21 +2198,16 @@ void xlsx_producer::write_worksheet(const relationship &rel) } } - if (!any_non_null) + if (any_non_null) { - continue; + write_attribute("spans", std::to_string(min) + ":" + std::to_string(max)); } - write_start_element(xmlns, "row"); - - write_attribute("r", row.front().row()); - write_attribute("spans", std::to_string(min) + ":" + std::to_string(max)); - - if (ws.has_row_properties(row.front().row())) + if (ws.has_row_properties(row_index)) { - const auto &props = ws.row_properties(row.front().row()); + const auto &props = ws.row_properties(row_index); - if (props.custom_height) + if (props.custom_height || props.height.is_set()) { write_attribute("customHeight", write_bool(true)); }