From b899c9db5cf911217f2be0a8ab9ddcc395cf127d Mon Sep 17 00:00:00 2001 From: TataMata Date: Mon, 6 Nov 2017 11:55:06 +0100 Subject: [PATCH] Fix bug in cell style assingment There was a bug introduced in version 1.2 in reading styles. As from the Office Open XML documentation: --- source/detail/serialization/xlsx_consumer.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/source/detail/serialization/xlsx_consumer.cpp b/source/detail/serialization/xlsx_consumer.cpp index c7b8bc81..15681610 100644 --- a/source/detail/serialization/xlsx_consumer.cpp +++ b/source/detail/serialization/xlsx_consumer.cpp @@ -1704,6 +1704,21 @@ void xlsx_consumer::read_shared_workbook_user_data() { } +namespace { +void set_style_by_xfid( + const std::vector>& styles, + std::size_t xfid, optional& style +) { + for(auto item : styles) + { + if( item.second == xfid ) + { + style = item.first.name; + } + } +} +} + void xlsx_consumer::read_stylesheet() { target_.impl().stylesheet_ = detail::stylesheet(); @@ -2326,7 +2341,7 @@ void xlsx_consumer::read_stylesheet() new_format.pivot_button_ = record.first.pivot_button_; new_format.quote_prefix_ = record.first.quote_prefix_; - new_format.style = styles.at(record.second).first.name; + set_style_by_xfid(styles, record.second, new_format.style); } }