roo-rb / roo

Roo provides an interface to spreadsheets of several sorts.
MIT License
2.78k stars 503 forks source link

to_csv not working with ODS when there is a boolean cell #545

Open LocoDelAssembly opened 3 years ago

LocoDelAssembly commented 3 years ago

The problem seems to be at: https://github.com/roo-rb/roo/blob/3ed05e1caef0ce3c5db5c19f1fa14e6f74193079/lib/roo/formatters/csv.rb#L46

However it works if the cell rather than having "TRUE" as boolean type cell it has "=TRUE()". Would break something if :boolean was handled just as if it was a formula?

2.7.1 :036 > ap CSV.new(Roo::Spreadsheet.open('./test-fail.ods').to_csv).first
Traceback (most recent call last):
        2: from (irb):35
        1: from (irb):36:in `rescue in irb_binding'
NoMethodError (undefined method `sheet_for' for #<Roo::OpenOffice:0x0000557c95ac7878>)
Did you mean?  sheet
2.7.1 :037 > ap CSV.new(Roo::Spreadsheet.open('./test-pass.ods').to_csv).first
[
    [ 0] "1",
    [ 1] "1.3",
    [ 2] "a",
    [ 3] "25/10/2020",
    [ 4] "2020-10-25",
    [ 5] "3324.23",
    [ 6] "23423",
    [ 7] "0.05",
    [ 8] "01:32:00",
    [ 9] "10:39:00",
    [10] "1.75",
    [11] "true",
    [12] "sarasum"
]
 => nil 

Samples: test.zip

wu-lee commented 3 years ago

Thanks - I am seeing exactly this issue too.