From 3eb06bac0d393a8c373b8881fad176209650029d Mon Sep 17 00:00:00 2001 From: Crzyrndm Date: Sat, 23 Jun 2018 22:29:57 +1200 Subject: [PATCH] serialisation of custom row format property added --- include/xlnt/worksheet/row_properties.hpp | 5 +++++ source/detail/serialization/xlsx_consumer.cpp | 11 ++++++++++- source/detail/serialization/xlsx_producer.cpp | 19 ++++++++++++++----- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/include/xlnt/worksheet/row_properties.hpp b/include/xlnt/worksheet/row_properties.hpp index 4fcb6fa5..2e724f20 100644 --- a/include/xlnt/worksheet/row_properties.hpp +++ b/include/xlnt/worksheet/row_properties.hpp @@ -54,6 +54,11 @@ public: /// bool hidden = false; + /// + /// True if row style should be applied + /// + optional custom_format; + /// /// The index to the style used by all cells in this row /// diff --git a/source/detail/serialization/xlsx_consumer.cpp b/source/detail/serialization/xlsx_consumer.cpp index 0c3ef808..3a7f5600 100644 --- a/source/detail/serialization/xlsx_consumer.cpp +++ b/source/detail/serialization/xlsx_consumer.cpp @@ -659,7 +659,16 @@ void xlsx_consumer::read_worksheet_sheetdata() row_properties.dy_descent = parser().attribute(qn("x14ac", "dyDescent")); } - skip_attributes({ "customFormat", "s", "customFont", + if (parser().attribute_present("s")) + { + row_properties.style.set(static_cast(std::stoull(parser().attribute("s")))); + } + if (parser().attribute_present("customFormat")) + { + row_properties.custom_format.set(parser().attribute("customFormat")); + } + + skip_attributes({ "customFont", "outlineLevel", "collapsed", "thickTop", "thickBot", "ph", "spans" }); diff --git a/source/detail/serialization/xlsx_producer.cpp b/source/detail/serialization/xlsx_producer.cpp index 64937d03..a11ba74f 100644 --- a/source/detail/serialization/xlsx_producer.cpp +++ b/source/detail/serialization/xlsx_producer.cpp @@ -2362,11 +2362,6 @@ void xlsx_producer::write_worksheet(const relationship &rel) write_attribute("width", (props.width.get() * 7 + 5) / 7); } - if (props.custom_width) - { - write_attribute("customWidth", write_bool(true)); - } - if (props.style.is_set()) { write_attribute("style", props.style.get()); @@ -2377,6 +2372,11 @@ void xlsx_producer::write_worksheet(const relationship &rel) write_attribute("hidden", write_bool(true)); } + if (props.custom_width) + { + write_attribute("customWidth", write_bool(true)); + } + write_end_element(xmlns, "col"); } @@ -2440,6 +2440,15 @@ void xlsx_producer::write_worksheet(const relationship &rel) { const auto &props = ws.row_properties(row); + if (props.style.is_set()) + { + write_attribute("s", props.style.get()); + } + if (props.custom_format.is_set()) + { + write_attribute("customFormat", write_bool(props.custom_format.get())); + } + if (props.height.is_set()) { auto height = props.height.get();