Class: Spreadsheet::Excel::Row
- Defined in:
- lib/spreadsheet/excel/row.rb
Overview
Excel-specific Row methods
Constant Summary collapse
- LEAP_ERROR =
The Excel date calculation erroneously assumes that 1900 is a leap-year. All Dates after 28.2.1900 are off by one.
Date.new 1900, 2, 28
Instance Attribute Summary
Attributes inherited from Row
#formats, #height, #idx, #worksheet
Instance Method Summary collapse
-
#[](idx, len = nil) ⇒ Object
Access data in this Row like you would in an Array.
-
#date(idx) ⇒ Object
Force convert the cell at idx to a Date.
-
#datetime(idx) ⇒ Object
Force convert the cell at idx to a DateTime.
- #each ⇒ Object
-
#to_a ⇒ Object
Returns data as an array.
Methods inherited from Row
#default_format, #default_format=, #first_used, #format, format_updater, #formatted, #formatted_size, #initialize, #inspect, #set_format, #update_format, updater
Methods included from Datatypes
Methods included from Compatibility
Constructor Details
This class inherits a constructor from Spreadsheet::Row
Instance Method Details
#[](idx, len = nil) ⇒ Object
Access data in this Row like you would in an Array. If a cell is formatted as a Date or DateTime, the decoded Date or DateTime value is returned.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/spreadsheet/excel/row.rb', line 31 def [] idx, len=nil if len idx = idx...(idx+len) end if idx.is_a? Range data = [] idx.each do |i| data.push enriched_data(i, at(i)) end data else enriched_data idx, at(idx) end end |
#date(idx) ⇒ Object
Force convert the cell at idx to a Date
15 16 17 |
# File 'lib/spreadsheet/excel/row.rb', line 15 def date idx _date at(idx) end |
#datetime(idx) ⇒ Object
Force convert the cell at idx to a DateTime
20 21 22 |
# File 'lib/spreadsheet/excel/row.rb', line 20 def datetime idx _datetime at(idx) end |
#each ⇒ Object
23 24 25 26 27 |
# File 'lib/spreadsheet/excel/row.rb', line 23 def each size.times do |idx| yield self[idx] end end |
#to_a ⇒ Object
Returns data as an array. If a cell is formatted as a Date or DateTime, the decoded Date or DateTime value is returned.
48 49 50 |
# File 'lib/spreadsheet/excel/row.rb', line 48 def to_a self[0...length] end |