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.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/spreadsheet/excel/row.rb', line 34 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 set_date at(idx) end |
#datetime(idx) ⇒ Object
Force convert the cell at idx to a DateTime
21 22 23 |
# File 'lib/spreadsheet/excel/row.rb', line 21 def datetime idx set_datetime at(idx) end |
#each ⇒ Object
25 26 27 28 29 |
# File 'lib/spreadsheet/excel/row.rb', line 25 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.
52 53 54 |
# File 'lib/spreadsheet/excel/row.rb', line 52 def to_a self[0...length] end |