diff --git a/source/detail/serialization/xlsx_consumer.cpp b/source/detail/serialization/xlsx_consumer.cpp index d23d35db1..ea64b1318 100644 --- a/source/detail/serialization/xlsx_consumer.cpp +++ b/source/detail/serialization/xlsx_consumer.cpp @@ -272,8 +272,8 @@ Cell parse_cell(xlnt::row_t row_arg, xml::parser *parser) if (level == 2) { // -> numeric values - // -> inline string - if (string_equal(parser->name(), "v") || string_equal(parser->name(), "is")) + // -> inline string + if (string_equal(parser->name(), "v")) { c.value += std::move(parser->value()); } @@ -283,6 +283,14 @@ Cell parse_cell(xlnt::row_t row_arg, xml::parser *parser) c.formula_string += std::move(parser->value()); } } + else if (level == 3) + { + // -> inline string + if (string_equal(parser->name(), "t")) + { + c.value += std::move(parser->value()); + } + } break; } case xml::parser::start_namespace_decl: @@ -561,6 +569,7 @@ cell xlsx_consumer::read_cell() else if (current_element == qn("spreadsheetml", "is")) // CT_Rst { expect_start_element(qn("spreadsheetml", "t"), xml::content::simple); + has_value = true; value_string = read_text(); expect_end_element(qn("spreadsheetml", "t")); } diff --git a/tests/data/Issue445_inline_str.xlsx b/tests/data/Issue445_inline_str.xlsx new file mode 100644 index 000000000..4085593b6 Binary files /dev/null and b/tests/data/Issue445_inline_str.xlsx differ diff --git a/tests/workbook/serialization_test_suite.cpp b/tests/workbook/serialization_test_suite.cpp index 56660f89b..289e08cad 100644 --- a/tests/workbook/serialization_test_suite.cpp +++ b/tests/workbook/serialization_test_suite.cpp @@ -91,6 +91,8 @@ class serialization_test_suite : public test_suite register_test(test_streaming_read); register_test(test_streaming_write); register_test(test_load_save_german_locale); + register_test(test_Issue445_inline_str_load); + register_test(test_Issue445_inline_str_streaming_read); } bool workbook_matches_file(xlnt::workbook &wb, const xlnt::path &file) @@ -716,5 +718,23 @@ class serialization_test_suite : public test_suite test_round_trip_rw_custom_heights_widths(); std::locale::global(current);*/ } + + void test_Issue445_inline_str_load() + { + xlnt::workbook wb; + wb.load(path_helper::test_file("Issue445_inline_str.xlsx")); + auto ws = wb.active_sheet(); + auto cell = ws.cell("A1"); + xlnt_assert_equals(cell.value(), std::string("a")); + } + + void test_Issue445_inline_str_streaming_read() + { + xlnt::streaming_workbook_reader wbr; + wbr.open(path_helper::test_file("Issue445_inline_str.xlsx")); + wbr.begin_worksheet("Sheet"); + auto cell = wbr.read_cell(); + xlnt_assert_equals(cell.value(), std::string("a")); + } }; static serialization_test_suite x;