Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect parse for Excelx with inline rich text #504

Merged
merged 1 commit into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions lib/roo/excelx/sheet_doc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Binary file added test/files/richtext_example.xlsx
Binary file not shown.
7 changes: 7 additions & 0 deletions test/roo/test_excelx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down