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

Exporting link url when converting spreadsheet to csv #93

Merged
merged 1 commit into from
Jan 25, 2014
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
2 changes: 2 additions & 0 deletions lib/roo/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -778,6 +778,8 @@ def cell_to_csv(row, col, sheet)
onecell.to_s
when :time
Roo::Base.integer_to_timestring(onecell)
when :link
%{"#{onecell.url.gsub(/"/,'""')}"}
else
raise "unhandled celltype #{celltype(row,col,sheet)}"
end || ""
Expand Down
1 change: 1 addition & 0 deletions test/files/link.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
"http://www.google.com"
14 changes: 13 additions & 1 deletion test/test_roo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1113,7 +1113,19 @@ def test_boolean_to_csv
end
end
end

def test_link_to_csv
with_each_spreadsheet(:name=>'link',:format=>:excel) do |oo|
Dir.mktmpdir do |tempdir|
csv_output = File.join(tempdir,'link.csv')
assert oo.to_csv(csv_output)
assert File.exists?(csv_output)
puts `diff --strip-trailing-cr #{TESTDIR}/link.csv #{csv_output}`
assert_equal "", `diff --strip-trailing-cr #{TESTDIR}/link.csv #{csv_output}`
# --strip-trailing-cr is needed because the test-file use 0A and
# the test on an windows box generates 0D 0A as line endings
end
end
end
def test_date_time_yaml
with_each_spreadsheet(:name=>'time-test') do |oo|
expected =
Expand Down