class Excelgrip::Excel

Excel Application Class ==============

Public Class Methods

new(visible=true) click to toggle source
# File lib/excelgrip.rb, line 16
def initialize(visible=true)
  @raw_object = WIN32OLE.new('EXCEL.Application')
  WIN32OLE.const_load(@raw_object, Excel)
  @raw_object.visible = visible
  @raw_object.displayAlerts = false
end

Public Instance Methods

copy_book(template_filename = nil) click to toggle source
# File lib/excelgrip.rb, line 23
def copy_book(template_filename = nil)
  if (template_filename == nil) or (template_filename == "") then
    workbook = @raw_object.Workbooks.add
  else
    fullpath = FileSystemObject.instance.fullpath(template_filename)
    workbook = @raw_object.workbooks.add(fullpath)
  end
  Workbook.new(workbook)
end
open_book(filename) click to toggle source
# File lib/excelgrip.rb, line 33
def open_book(filename)
  fullpath = FileSystemObject.instance.fullpath(filename)
  workbook = @raw_object.workbooks.open({'filename'=> fullpath})
  Workbook.new(workbook)
end
quit() click to toggle source
# File lib/excelgrip.rb, line 47
def quit
  @raw_object.Quit
  @raw_object = nil
end
workbooks(index=nil) click to toggle source
# File lib/excelgrip.rb, line 39
def workbooks(index=nil)
  if index
    Workbook.new(@raw_object.Workbooks(index))
  else
    Workbooks.new(@raw_object.Workbooks)
  end
end