Class: Cosmos::ExcelSpreadsheet

Inherits:
Object
  • Object
show all
Defined in:
lib/cosmos/win32/excel.rb

Overview

This class will take an Excel spreadsheet and build an easily manipulated spreadsheet in ruby

Defined Under Namespace

Classes: ExcelWorksheet

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(filename) ⇒ ExcelSpreadsheet

Returns a new instance of ExcelSpreadsheet.



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/cosmos/win32/excel.rb', line 37

def initialize (filename)
  excel = WIN32OLE.new('excel.application')
  excel.visible = false
  wb = excel.workbooks.open(filename)

  @worksheets = []

  count = wb.worksheets.count
  count.times do |index|
    ws = wb.worksheets(index + 1)
    @worksheets << ExcelWorksheet.new(ws)
  end

  excel.DisplayAlerts = false
  excel.quit
  excel = nil
  GC.start
end

Instance Attribute Details

#worksheetsObject (readonly)

Returns the value of attribute worksheets.



20
21
22
# File 'lib/cosmos/win32/excel.rb', line 20

def worksheets
  @worksheets
end