Class: Rasta::Spreadsheet::Excel

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/rasta/spreadsheet.rb

Overview

Singleton Class to store Excel Instance

:visible Make the Excel Spreadsheet visible when processing :continue Continue from a bookmark :pagecount Continue for n pages after a bookmark

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeExcel

Returns a new instance of Excel.



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/rasta/spreadsheet.rb', line 26

def initialize
  @visible = false
  @continue = false
  @currentrecord = 0
  @currentpage = 0
  @pagecount = 0 
  @recordcount = 0
  @open_workbooks = []
  @excel = WIN32OLE::new('excel.Application')
  WIN32OLE.const_load(@excel, ExcelConst) if ExcelConst.constants == []    # load Excel constants
end

Instance Attribute Details

#continueObject

Returns the value of attribute continue.



25
26
27
# File 'lib/rasta/spreadsheet.rb', line 25

def continue
  @continue
end

#currentpageObject

Returns the value of attribute currentpage.



25
26
27
# File 'lib/rasta/spreadsheet.rb', line 25

def currentpage
  @currentpage
end

#currentrecordObject

Returns the value of attribute currentrecord.



25
26
27
# File 'lib/rasta/spreadsheet.rb', line 25

def currentrecord
  @currentrecord
end

#excelObject (readonly)

Returns the value of attribute excel.



24
25
26
# File 'lib/rasta/spreadsheet.rb', line 24

def excel
  @excel
end

#pagecountObject

Returns the value of attribute pagecount.



25
26
27
# File 'lib/rasta/spreadsheet.rb', line 25

def pagecount
  @pagecount
end

#recordcountObject

Returns the value of attribute recordcount.



25
26
27
# File 'lib/rasta/spreadsheet.rb', line 25

def recordcount
  @recordcount
end

#visibleObject

Returns the value of attribute visible.



24
25
26
# File 'lib/rasta/spreadsheet.rb', line 24

def visible
  @visible
end

Instance Method Details

#cleanupObject



42
43
44
45
46
47
48
49
# File 'lib/rasta/spreadsheet.rb', line 42

def cleanup
  if !@excel.visible
    while @excel.ActiveWorkbook
      @excel.ActiveWorkbook.Close(0)
    end
    @excel.Quit
  end  
end

#open(filename) ⇒ Object



38
39
40
# File 'lib/rasta/spreadsheet.rb', line 38

def open(filename)
  @excel.Workbooks.Open(File.expand_path(filename))
end