| 1 |
|
| 2 |
require 'win32ole' |
| 3 |
|
| 4 |
|
| 5 |
application = WIN32OLE.new('Excel.Application') |
| 6 |
|
| 7 |
application.visible = true |
| 8 |
workbook = application.Workbooks.Add(); |
| 9 |
sheet = workbook.Worksheets(1); |
| 10 |
sheetS = workbook.Worksheets |
| 11 |
puts "The number of sheets is #{sheetS.count}" |
| 12 |
puts "Now add 2 sheets after of `#{sheet.name}`" |
| 13 |
sheetS.add({'count'=>2, 'after'=>sheet}) |
| 14 |
puts "The number of sheets is #{sheetS.count}" |
| 15 |
|
| 16 |
print "Now quit Excel... Please enter." |
| 17 |
gets |
| 18 |
|
| 19 |
application.ActiveWorkbook.Close(0); |
| 20 |
application.Quit(); |
| 21 |
|