Merge remote-tracking branch 'xpol/shared-string-with-different-formatted-parts' into styles-refactoring

This commit is contained in:
Thomas Fussell 2016-05-14 09:30:05 -04:00
commit e1e29e1f30
3 changed files with 24 additions and 2 deletions

View File

@ -68,9 +68,17 @@ 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"))
{
text += r_node.get_child("t").get_text();
}
}
strings.push_back(std::move(text));
}
}

View File

@ -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<std::string>();
TS_ASSERT_EQUALS(val, "abcdef");
}
xlnt::workbook date_mac_1904()
{
auto path = PathHelper::GetDataDirectory("/reader/date_1904.xlsx");

Binary file not shown.