Skip to content

Commit

Permalink
Fix that Excelx link cells would blow up if the link contents was not…
Browse files Browse the repository at this point in the history
… a string. roo-rb#92
  • Loading branch information
Empact committed Dec 23, 2013
1 parent 316481d commit b10ae12
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG
@@ -1,3 +1,8 @@
== 1.13.2 2013-12-23

* bugfixes
* Fix that Excelx link-cells would blow up if the value wasn't a string. Due to the way Spreadsheet::Link is implemented the link text must be treated as a string. #92

== 1.13.1 2013-12-23

* bugfixes
Expand Down
2 changes: 1 addition & 1 deletion lib/roo/excelx.rb
Expand Up @@ -376,7 +376,7 @@ def set_cell_values(sheet,x,y,i,v,value_type,formula,
v
end

@cell[sheet][key] = Spreadsheet::Link.new(@hyperlink[sheet][key], @cell[sheet][key]) if hyperlink?(y,x+i)
@cell[sheet][key] = Spreadsheet::Link.new(@hyperlink[sheet][key], @cell[sheet][key].to_s) if hyperlink?(y,x+i)
@excelx_type[sheet] ||= {}
@excelx_type[sheet][key] = excelx_type
@excelx_value[sheet] ||= {}
Expand Down
15 changes: 15 additions & 0 deletions spec/lib/roo/excelx_spec.rb
Expand Up @@ -20,4 +20,19 @@
end
end
end

describe '#cell' do
context 'for a link cell' do
context 'with numeric contents' do
subject {
Roo::Excelx.new('test/files/numeric-link.xlsx').cell('A', 1)
}

it 'returns a link with the number as a string value' do
expect(subject).to be_a(Spreadsheet::Link)
expect(subject).to eq("8675309.0")
end
end
end
end
end
Binary file added test/files/numeric-link.xlsx
Binary file not shown.

0 comments on commit b10ae12

Please sign in to comment.