Skip to content
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
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
## Unreleased
- Fix gsub! usage for open office documents on a frozen string [580](https://github.com/roo-rb/roo/pull/580)
- Fix gsub! usage for open office documents on a frozen string [581](https://github.com/roo-rb/roo/pull/581)
- Add support for boolean values in open office files that were generated via Google Sheets [580](https://github.com/roo-rb/roo/pull/580)

### Changed/Added
- Roo::Base#each_with_pagename returns Enumerator Object [576](https://github.com/roo-rb/roo/pull/576)
Expand Down
5 changes: 4 additions & 1 deletion lib/roo/open_office.rb
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,10 @@ def set_cell_values(sheet, x, y, i, v, value_type, formula, table_cell, str_v, s
@style[sheet][key] = style_name
case @cell_type[sheet][key]
when :float
@cell[sheet][key] = (table_cell.attributes['value'].to_s.include?(".") || table_cell.children.first.text.include?(".")) ? v.to_f : v.to_i
value = (table_cell.attributes['value'].to_s.include?(".") || table_cell.children.first.text.include?(".")) ? v.to_f : v.to_i
value = 'true' if formula == '=TRUE()'
value = 'false' if formula == '=FALSE()'
@cell[sheet][key] = value
when :percentage
@cell[sheet][key] = v.to_f
when :string
Expand Down
Binary file added test/files/boolean-from-google-sheets.ods
Binary file not shown.
Binary file added test/files/boolean-from-google-sheets.xlsx
Binary file not shown.
18 changes: 18 additions & 0 deletions test/test_roo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,24 @@ def test_cell_boolean
end
end

def test_cell_boolean_from_google_sheets
with_each_spreadsheet(:name=>'boolean-from-google-sheets', :format=>[:openoffice, :excelx]) do |oo|
if oo.class == Roo::Excelx
assert_equal true, oo.cell(1, 1), "failure in #{oo.class}"
assert_equal false, oo.cell(2, 1), "failure in #{oo.class}"

cell = oo.sheet_for(oo.default_sheet).cells[[1, 1,]]
assert_equal 'TRUE', cell.formatted_value

cell = oo.sheet_for(oo.default_sheet).cells[[2, 1,]]
assert_equal 'FALSE', cell.formatted_value
else
assert_equal "true", oo.cell(1,1), "failure in #{oo.class}"
assert_equal "false", oo.cell(2,1), "failure in #{oo.class}"
end
end
end

def test_cell_multiline
with_each_spreadsheet(:name=>'paragraph', :format=>[:openoffice, :excelx]) do |oo|
assert_equal "This is a test\nof a multiline\nCell", oo.cell(1,1)
Expand Down