Class: POI::Worksheet
Instance Method Summary collapse
-
#[](row_index) ⇒ Object
Accepts a Fixnum or a String as the row_index.
- #first_row ⇒ Object
-
#initialize(worksheet, workbook) ⇒ Worksheet
constructor
A new instance of Worksheet.
- #last_row ⇒ Object
- #name ⇒ Object
- #poi_worksheet ⇒ Object
- #rows ⇒ Object
- #workbook ⇒ Object
Constructor Details
#initialize(worksheet, workbook) ⇒ Worksheet
Returns a new instance of Worksheet.
31 32 33 34 |
# File 'lib/poi/workbook/worksheet.rb', line 31 def initialize(worksheet, workbook) @worksheet = worksheet @workbook = workbook end |
Instance Method Details
#[](row_index) ⇒ Object
Accepts a Fixnum or a String as the row_index
row_index as Fixnum: returns the 0-based row
row_index as String: assumes a cell reference within this sheet
if the value of the reference is non-nil the value is returned,
otherwise the referenced cell is returned
59 60 61 62 63 64 65 66 67 |
# File 'lib/poi/workbook/worksheet.rb', line 59 def [](row_index) if Fixnum === row_index rows[row_index] else ref = org.apache.poi.ss.util.CellReference.new(row_index) cell = rows[ref.row][ref.col] cell && cell.value ? cell.value : cell end end |
#first_row ⇒ Object
40 41 42 |
# File 'lib/poi/workbook/worksheet.rb', line 40 def first_row @worksheet.first_row_num end |
#last_row ⇒ Object
44 45 46 |
# File 'lib/poi/workbook/worksheet.rb', line 44 def last_row @worksheet.last_row_num end |
#name ⇒ Object
36 37 38 |
# File 'lib/poi/workbook/worksheet.rb', line 36 def name @worksheet.sheet_name end |
#poi_worksheet ⇒ Object
69 70 71 |
# File 'lib/poi/workbook/worksheet.rb', line 69 def poi_worksheet @worksheet end |
#rows ⇒ Object
48 49 50 |
# File 'lib/poi/workbook/worksheet.rb', line 48 def rows @rows ||= Rows.new(self) end |
#workbook ⇒ Object
73 74 75 |
# File 'lib/poi/workbook/worksheet.rb', line 73 def workbook @workbook end |