lib/roo/excel.rb in roo-1.12.2 vs lib/roo/excel.rb in roo-1.13.0
- old
+ new
@@ -17,13 +17,15 @@
# Parameter packed: :zip - File is a zip-file
def initialize(filename, options = {}, deprecated_file_warning = :error)
if Hash === options
packed = options[:packed]
file_warning = options[:file_warning] || :error
+ mode = options[:mode] || "rb+"
else
- warn 'Supplying `packed` or `file_warning` as separate arguments to `Roo::Excel.new` is deprected. Use an options hash instead.'
+ warn 'Supplying `packed` or `file_warning` as separate arguments to `Roo::Excel.new` is deprecated. Use an options hash instead.'
packed = options
+ mode = "rb+"
file_warning = deprecated_file_warning
end
file_type_check(filename,'.xls','an Excel', file_warning, packed)
make_tmpdir do |tmpdir|
@@ -33,11 +35,11 @@
@filename = filename
unless File.file?(@filename)
raise IOError, "file #{@filename} does not exist"
end
- @workbook = Spreadsheet.open(filename)
+ @workbook = Spreadsheet.open(filename, mode)
end
super(filename, options)
@formula = Hash.new
@fonts = Hash.new
end
@@ -272,10 +274,11 @@
# Get the contents of a cell, accounting for the
# way formula stores the value
def read_cell_content(row, idx)
cell = row.at(idx)
+ cell = row[idx] if row[idx].class == Spreadsheet::Link
cell = cell.value if cell.class == Spreadsheet::Formula
cell
end
# Test the cell to see if it's a valid date/time.
@@ -334,9 +337,12 @@
cell = read_cell_content(row, idx)
case cell
when Float, Integer, Fixnum, Bignum
value_type = :float
value = cell.to_f
+ when Spreadsheet::Link
+ value_type = :link
+ value = cell
when String, TrueClass, FalseClass
value_type = :string
value = cell.to_s
else
value_type = cell.class.to_s.downcase.to_sym