Browse files

Add suport for boolean values to Excelx files

  • Loading branch information...
1 parent c28ba46 commit 572fc004f258006c756252a26ec38156d0534cbd Hugh Mcgowan committed Jan 31, 2009
Showing with 10 additions and 1 deletion.
  1. +6 −0 lib/roo/excelx.rb
  2. BIN test/boolean.xlsx
  3. +4 −1 test/test_roo.rb
View
6 lib/roo/excelx.rb
@@ -385,6 +385,9 @@ def read_cells(sheet=nil)
if row.name == 'c'
if row.attributes['t'] == 's'
tmp_type = :shared
+ elsif row.attributes['t'] == 'b'
+ tmp_type = :boolean
+
else
s_attribute = row.attributes['s']
format = attribute2format(s_attribute)
@@ -426,6 +429,9 @@ def read_cells(sheet=nil)
vt = :string
str_v = @shared_table[cell.text.to_i]
excelx_type = :string
+ elsif tmp_type == :boolean
+ vt = :boolean
+ cell.text.to_i == 1 ? v = 'TRUE' : v = 'FALSE'
elsif tmp_type == :date
vt = :date
v = cell.text
View
BIN test/boolean.xlsx
Binary file not shown.
View
5 test/test_roo.rb
@@ -4858,7 +4858,10 @@ def test_cell_excel_boolean
assert_equal "false", oo.cell(2,1)
end
if EXCELX
- # TODO. need a source file to test with
+ oo = Excelx.new(File.join("test","boolean.xlsx"))
+ oo.default_sheet = oo.sheets.first
+ assert_equal "TRUE", oo.cell(1,1)
+ assert_equal "FALSE", oo.cell(2,1)
end
end

0 comments on commit 572fc00

Please sign in to comment.