a management date bug?

11 views
Skip to first unread message

Giovanni Messina

unread,
Jul 23, 2009, 4:07:49 AM7/23/09
to ruby...@googlegroups.com
Hi everyone,

first tanks for this gem!

second, if I try to import a cell with date format "dd/mm/yy hh:mm" with the value xx/xx/xx 10.00 I receive an error message

irb(main):007:0> ex = Excel.new("Dir_Priv_B1707.xls")
=> #<Excel:0xb72804f8 @first_column={}, @formula={}, @cell={}, @tmpdir="oo_4468", @file_warning=:error, @default_sheet="Dir_Priv_B1707", @workbook=#<Spreadsheet::Excel::Workbook:0xffffffdb93e080 @date_base=1899-12-31T00:00:00+00:00 @bof=2057 @ole=#<Ole::Storage::RangesIOMigrateable:0xb727bbb0> @boundsheets=1 @version=1536 @default_format=#<Spreadsheet::Format:0xb72694ec> @io=#<File:0xb728023c> @encoding=UTF-16LE @formats=Array[77] @fonts=Array[35] @worksheets=Array[1] @sst=Array[375] @offsets=Hash[5] @changes=Hash[0]>, @last_row={}, @cell_type={}, @header_line=1, @filename="Dir_Priv_B1707.xls", @cells_read={}, @first_row={}, @last_column={}, @fonts={}>

irb(main):008:0> ex.cell(1,3)
ArgumentError: invalid date
    from /usr/lib/ruby/1.8/date.rb:1519:in `new'
    from /usr/lib/ruby/gems/1.8/gems/spreadsheet-0.6.4/lib/spreadsheet/excel/row.rb:73:in `_datetime'
    from /usr/lib/ruby/gems/1.8/gems/spreadsheet-0.6.4/lib/spreadsheet/excel/row.rb:21:in `datetime'
    from /usr/lib/ruby/gems/1.8/gems/roo-1.3.6/lib/roo/excel.rb:362:in `read_cell_date_or_time'
    from /usr/lib/ruby/gems/1.8/gems/roo-1.3.6/lib/roo/excel.rb:308:in `read_cells'
    from /usr/lib/ruby/gems/1.8/gems/roo-1.3.6/lib/roo/excel.rb:303:in `each'
    from /usr/lib/ruby/gems/1.8/gems/roo-1.3.6/lib/roo/excel.rb:303:in `read_cells'
    from /usr/lib/ruby/gems/1.8/gems/spreadsheet-0.6.4/lib/spreadsheet/worksheet.rb:112:in `call'
    from /usr/lib/ruby/gems/1.8/gems/spreadsheet-0.6.4/lib/spreadsheet/worksheet.rb:112:in `each'
    from /usr/lib/ruby/gems/1.8/gems/spreadsheet-0.6.4/lib/spreadsheet/worksheet.rb:111:in `upto'
    from /usr/lib/ruby/gems/1.8/gems/spreadsheet-0.6.4/lib/spreadsheet/worksheet.rb:111:in `each'
    from /usr/lib/ruby/gems/1.8/gems/spreadsheet-0.6.4/lib/spreadsheet/excel/worksheet.rb:34:in `each'
    from /usr/lib/ruby/gems/1.8/gems/roo-1.3.6/lib/roo/excel.rb:302:in `read_cells'
    from /usr/lib/ruby/gems/1.8/gems/roo-1.3.6/lib/roo/excel.rb:109:in `cell'
    from (irb):8

I found that the numerical value of the cell is a periodic
if this is approximated by hand to the fifth decimal import no more problems
I think the problem is therefore the management of this format if the numbers have gone more than 5 decimal places, as in this case

thanks

Gio

Thomas Preymesser

unread,
Jul 23, 2009, 6:00:12 AM7/23/09
to ruby-roo
Hi Gio,

On Jul 23, 10:07 am, Giovanni Messina <messina....@gmail.com> wrote:
> Hi everyone,
>
> first tanks for this gem!
>
> second, if I try to import a cell with date format "dd/mm/yy hh:mm" with the
> value xx/xx/xx 10.00 I receive an error message

could you send me a spreadsheet file (with no confidential data in it)
which produces this error?
I'm afraid, that this is not a bug in roo but in the 'spreadsheet'
gem, which is used for old Excel files. I can't do much in roo itself.
Roo tries to get the cell value via the spreadsheet gem and this gem
raises this exception.
I will send this error report to the spreadsheet gem developers.

-Thomas
Reply all
Reply to author
Forward
0 new messages