メソッドを確認する
require 'win32ole'
excel = WIN32OLE.new('EXCEL.Application')
puts excel.ole_methods # エクセル本体の関数
puts excel.WorksheetFunction.ole_methods # エクセルのセルとかで使う関数
excel.quit
すべてのシートのA1を表示する
require 'win32ole'
class Excel
end
excel = WIN32OLE.new('EXCEL.Application')
WIN32OLE.const_load(excel, Excel)
begin
ARGV.each { |fn|
book = excel.workbooks.open(fn)
begin
book.worksheets.count.times { |cnt|
sheet = book.worksheets(cnt+1)
puts sheet.range("a1").value
}
rescue
puts $!
ensure
book.close
end
}
rescue
puts $!
ensure
excel.quit
end