Class: Spreadsheet::Excel::Row

Inherits:
Row
  • Object
show all
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

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

append_features

Methods included from Compatibility

#ivar_name, #method_name

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

#eachObject



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_aObject

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