diff --git a/lib/roo/excelx/sheet_doc.rb b/lib/roo/excelx/sheet_doc.rb index 6da4c26a..4a91da32 100755 --- a/lib/roo/excelx/sheet_doc.rb +++ b/lib/roo/excelx/sheet_doc.rb @@ -101,12 +101,7 @@ def cell_from_xml(cell_xml, hyperlink, coordinate, empty_cell=true) cell_xml_children.each do |cell| case cell.name when 'is' - content = +"" - cell.children.each do |inline_str| - if inline_str.name == 't' - content << inline_str.content - end - end + content = cell.search('t').map(&:content).join unless content.empty? return Excelx::Cell.cell_class(:string).new(content, formula, style, hyperlink, coordinate) end diff --git a/test/files/richtext_example.xlsx b/test/files/richtext_example.xlsx new file mode 100644 index 00000000..48dc1ee6 Binary files /dev/null and b/test/files/richtext_example.xlsx differ diff --git a/test/roo/test_excelx.rb b/test/roo/test_excelx.rb index 9d460afe..2c25476b 100644 --- a/test/roo/test_excelx.rb +++ b/test/roo/test_excelx.rb @@ -320,6 +320,13 @@ def test_base_dates_in_excelx end end + def test_parsing_xlsx_with_richtext + xlsx = roo_class.new(File.join(TESTDIR, "richtext_example.xlsx")) + + assert_equal "Example richtext", xlsx.cell("a", 1) + assert_equal "Example richtext", xlsx.cell("b", 1) + end + def roo_class Roo::Excelx end