Skip to content

Commit

Permalink
Merge pull request #492 from weilandia/491-fix-bad-link-bug
Browse files Browse the repository at this point in the history
Closes #491 add nil check for hyperlink['id']
  • Loading branch information
chopraanmol1 authored Jan 29, 2019
2 parents 4acaef8 + 0479c16 commit faf1b43
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/roo/excelx/relationships.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def to_a
private

def extract_relationships
return [] unless doc_exists?
return {} unless doc_exists?

doc.xpath('/Relationships/Relationship').each_with_object({}) do |rel, hash|
hash[rel['Id']] = rel
Expand Down
Binary file added test/files/bad_link.xlsx
Binary file not shown.
5 changes: 5 additions & 0 deletions test/roo/test_excelx.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,11 @@ def test_excelx_links
end
end

def test_handles_link_without_hyperlink
workbook = Roo::Spreadsheet.open(File.join(TESTDIR, "bad_link.xlsx"))
assert_equal "Test", workbook.cell(1, 1)
end

# Excel has two base date formats one from 1900 and the other from 1904.
# see #test_base_dates_in_excel
def test_base_dates_in_excelx
Expand Down

0 comments on commit faf1b43

Please sign in to comment.