lib/rspreadsheet/worksheet.rb in rspreadsheet-0.2.12 vs lib/rspreadsheet/worksheet.rb in rspreadsheet-0.2.14
- old
+ new
@@ -1,7 +1,9 @@
require 'rspreadsheet/row'
+require 'rspreadsheet/column'
require 'rspreadsheet/tools'
+require 'helpers/class_extensions'
# require 'forwardable'
module Rspreadsheet
class Worksheet
@@ -52,10 +54,11 @@
used_rows_range.collect{ |rowi| rows(rowi).nonemptycells }.flatten
end
#@!group XMLTiedArray connected methods
def rows(*params); subitems(*params) end
+ alias :row :rows
def prepare_subitem(rowi); Row.new(self,rowi) end
def rowcache; @itemcache end
#@!group How to get to cells? (syntactic sugar)
# Returns value of the cell given either by row,column integer coordinates of by address.
@@ -80,12 +83,17 @@
def cells(*params)
case params.length
when 0 then raise 'Not implemented yet' #TODO: return list of all cells
when 1..2
r,c = Rspreadsheet::Tools.a2c(*params)
- rows(r).andand.cells(c)
+ row(r).andand.cell(c)
else raise Exception.new('Wrong number of arguments.')
end
+ end
+ alias :cell :cells
+ def column(param)
+ r,coli = Rspreadsheet::Tools.a2c(1,param)
+ Column.new(self,coli)
end
# Allows syntax like sheet.F15. TO catch errors easier, allows only up to three uppercase letters in colum part, althought it won't be necessarry to restrict.
def method_missing method_name, *args, &block
if method_name.to_s.match(/^([A-Z]{1,3})(\d{1,8})(=?)$/)
row,col = Rspreadsheet::Tools.convert_cell_address_to_coordinates($~[1],$~[2])