mezza
unread,Jun 15, 2009, 7:05:48 AM6/15/09Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to ruby-roo
When trying to read an OpenOffice ODS file that contains empty rows
between rows with data, the gem seems to freeze - no errors are
logged.
As an example, suppose rows 1 and 3 contain one or more cells with
data (doesn't matter which columns) but row 2 is empty.
Here's the output from my IRB session:
---
require 'roo'
default formats are encoded in ISO-8859-1
=> true
oo = oo = Openoffice.new('/test.ods')
=> #<Openoffice:0x114e21c @doc=<UNDEFINED> ... </>, @cells_read={},
@first_row={}, @cell_type={}, @last_column={}, @filename="/test.ods",
@tmpdir="oo_1625", @file_warning=:error, @first_column={}, @cell={},
@file_nr=1, @default_sheet=nil, @last_row={}, @header_line=1,
@formula=
{}>
1.upto(3){|line| puts oo.row(line,oo.sheets.first)}
Northern bluefin tuna (E Stock)
---
And there the session gets stuck in a loop. I added a logger and think
the following patch is required:
Index: vendor/plugins/roo/lib/roo/generic_spreadsheet.rb
===================================================================
--- vendor/plugins/roo/lib/roo/generic_spreadsheet.rb (revision 681)
+++ vendor/plugins/roo/lib/roo/generic_spreadsheet.rb (working copy)
@@ -268,7 +268,7 @@
end
}
result = tmp_arr[1..-1]
- while result && result[-1] == nil
+ while result && !result.empty? && result[-1] == nil
result = result[0..-2]
end
result