Class: ODDB::Import::Excel

Inherits:
ODDB::Import show all
Defined in:
lib/oddb/import/excel.rb

Direct Known Subclasses

DatedExcel

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#reportObject (readonly)

Returns the value of attribute report.



10
11
12
# File 'lib/oddb/import/excel.rb', line 10

def report
  @report
end

Instance Method Details

#cell(row, idx) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/oddb/import/excel.rb', line 11

def cell(row, idx)
  if(cell = row[idx])
    case cell
    when Date, DateTime
      cell
    when Numeric
      cell.to_f
    else
      u(cell.to_s).strip
    end
  end
end

#import(io) ⇒ Object



23
24
25
26
27
28
# File 'lib/oddb/import/excel.rb', line 23

def import(io)
  workbook = parse(io)
  import_worksheet(workbook.worksheet(0))
  postprocess()
  report
end

#import_worksheet(worksheet) ⇒ Object



29
30
31
32
33
# File 'lib/oddb/import/excel.rb', line 29

def import_worksheet(worksheet)
  worksheet.each(@skip_rows) { |row|
    import_row(row)
  }
end

#parse(io) ⇒ Object



34
35
36
# File 'lib/oddb/import/excel.rb', line 34

def parse(io)
  Spreadsheet.open(io)
end