Class: Excelgrip::Excel
Overview
Excel Application Class ==============
Instance Method Summary
collapse
Methods inherited from GripWrapper
#inspect, #raw
Constructor Details
#initialize(visible = true) ⇒ Excel
Returns a new instance of Excel.
16
17
18
19
20
21
|
# 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
|
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class Excelgrip::GripWrapper
Instance Method Details
#copy_book(template_filename = nil) ⇒ Object
23
24
25
26
27
28
29
30
31
|
# 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) ⇒ Object
33
34
35
36
37
|
# 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 ⇒ Object
47
48
49
50
|
# File 'lib/excelgrip.rb', line 47
def quit
@raw_object.Quit
@raw_object = nil
end
|
#workbooks(index = nil) ⇒ Object
39
40
41
42
43
44
45
|
# 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
|