Merge pull request #446 from adamhooper/issue-445

Parse inlineStr values
This commit is contained in:
Thomas Fussell 2020-02-26 13:28:46 -05:00 committed by GitHub
commit ae6f9d2324
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 2 deletions

View File

@ -272,8 +272,8 @@ Cell parse_cell(xlnt::row_t row_arg, xml::parser *parser)
if (level == 2)
{
// <v> -> numeric values
// <is> -> inline string
if (string_equal(parser->name(), "v") || string_equal(parser->name(), "is"))
// <is><t> -> 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)
{
// <is><t> -> 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"));
}

Binary file not shown.

View File

@ -91,6 +91,8 @@ public:
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 @@ public:
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>(), 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>(), std::string("a"));
}
};
static serialization_test_suite x;