diff --git a/source/serialization/shared_strings_serializer.cpp b/source/serialization/shared_strings_serializer.cpp index 93591fe5..cb0e5d05 100644 --- a/source/serialization/shared_strings_serializer.cpp +++ b/source/serialization/shared_strings_serializer.cpp @@ -68,9 +68,18 @@ bool shared_strings_serializer::read_shared_strings(const xml_document &xml, std { strings.push_back(si_node.get_child("t").get_text()); } - else if (si_node.has_child("r")) + else if (si_node.has_child("r")) // possible multiple text entities. { - strings.push_back(si_node.get_child("r").get_child("t").get_text()); + std::string text; + for (const auto& r_node : si_node.get_children()) + { + if (r_node.get_name() == "r" && r_node.has_child("t")) + { + std::cout << r_node.get_child("t").get_text() << std::endl; + text += r_node.get_child("t").get_text(); + } + } + strings.push_back(std::move(text)); } } diff --git a/source/serialization/tests/test_read.hpp b/source/serialization/tests/test_read.hpp index 5533a516..1b8b5acd 100644 --- a/source/serialization/tests/test_read.hpp +++ b/source/serialization/tests/test_read.hpp @@ -184,6 +184,20 @@ public: TS_ASSERT_EQUALS(val, "Donald"); } + void test_read_shared_strings_multiple_r_nodes() + { + auto path = PathHelper::GetDataDirectory("/reader/shared_strings-multiple_r_nodes.xlsx"); + + xlnt::workbook wb; + xlnt::excel_serializer serializer(wb); + + serializer.load_workbook(path); + + auto ws = wb["Sheet1"]; + auto val = ws.get_cell("A1").get_value(); + TS_ASSERT_EQUALS(val, "abcdef"); + } + xlnt::workbook date_mac_1904() { auto path = PathHelper::GetDataDirectory("/reader/date_1904.xlsx"); diff --git a/tests/data/reader/shared_strings-multiple_r_nodes.xlsx b/tests/data/reader/shared_strings-multiple_r_nodes.xlsx new file mode 100644 index 00000000..d35130e5 Binary files /dev/null and b/tests/data/reader/shared_strings-multiple_r_nodes.xlsx differ