Class: ReadExcel::XLSXReader::Worksheet

Inherits:
Object
  • Object
show all
Defined in:
lib/read_excel/xlsx_reader.rb

Instance Method Summary collapse

Constructor Details

#initialize(worksheet) ⇒ Worksheet

Returns a new instance of Worksheet.



6
7
8
# File 'lib/read_excel/xlsx_reader.rb', line 6

def initialize(worksheet)
  @worksheet = worksheet
end

Instance Method Details

#nameObject



10
11
12
# File 'lib/read_excel/xlsx_reader.rb', line 10

def name
  @worksheet.sheet_name
end

#row(n) ⇒ Object



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/read_excel/xlsx_reader.rb', line 14

def row(n)
  values = []
  if @worksheet[n]
    count = @worksheet[n].size
    (0...count).each do |col|
      cell = @worksheet[n][col]
      if cell
        values << cell.value
      else
        values << cell
      end
    end
  end

  values
end