Skip to content

Commit

Permalink
Fixed handling of booleans in ods, xls.
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugh Mcgowan committed Jan 30, 2009
1 parent a100556 commit c28ba46
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/roo/excel.rb
Expand Up @@ -344,7 +344,11 @@ def read_cells(sheet=nil)
v = cell.to_f
when :text
vt = :string
str_v = cell.to_s('utf-8')
if cell.to_s.downcase == 'true'
str_v = cell.to_s
else
str_v = cell.to_s('utf-8')
end
when :date
if cell.to_s.to_f < 1.0
vt = :time
Expand Down
1 change: 1 addition & 0 deletions lib/roo/openoffice.rb
Expand Up @@ -324,6 +324,7 @@ def read_cells(sheet=nil)
elsif vt == 'float'
#
elsif vt == 'boolean'
v = tr.attributes['boolean-value']
#
else
# raise "unknown type #{vt}"
Expand Down
Binary file added test/boolean.ods
Binary file not shown.
Binary file added test/boolean.xls
Binary file not shown.
19 changes: 19 additions & 0 deletions test/test_roo.rb
Expand Up @@ -4843,4 +4843,23 @@ def test_cell_openoffice_html_escape
# test_openoffice_zipped catches the &quot;
end
end

def test_cell_excel_boolean
if EXCEL
oo = Excel.new(File.join("test","boolean.xls"))
oo.default_sheet = oo.sheets.first
assert_equal "TRUE", oo.cell(1,1)
assert_equal "FALSE", oo.cell(2,1)
end
if OPENOFFICE
oo = Openoffice.new(File.join("test","boolean.ods"))
oo.default_sheet = oo.sheets.first
assert_equal "true", oo.cell(1,1)
assert_equal "false", oo.cell(2,1)
end
if EXCELX
# TODO. need a source file to test with
end
end

end # class

0 comments on commit c28ba46

Please sign in to comment.