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

Add additional formula cell types: Date, TrueClass, FalseClass #366

Closed
wants to merge 2 commits into from
Closed
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: 1 addition & 1 deletion lib/roo/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ def cell_to_csv(row, col, sheet)
else
onecell.to_s
end
when DateTime
when Date, DateTime, TrueClass, FalseClass
onecell.to_s
else
fail "unhandled onecell-class #{onecell.class}"
Expand Down
21 changes: 21 additions & 0 deletions test/excelx/test_formula_to_csv.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
require 'test_helper'

class TestRooFormulaToCsv < Minitest::Test
def cell_to_csv(row, col)
Roo::Spreadsheet.open(
File.join(TESTDIR, 'formula_cell_types.xlsx')
).send('cell_to_csv', row, col, 'Sheet1')
end

def test_true_class
assert_equal 'true', cell_to_csv(1, 1)
end

def test_false_class
assert_equal 'false', cell_to_csv(2, 1)
end

def test_date_class
assert_equal '2017-01-01', cell_to_csv(3, 1)
end
end
Binary file added test/files/formula_cell_types.xlsx
Binary file not shown.