Ruby で Excel
Excel のシート名を列挙する
lesson001.rb
実行結果
require 'win32ole'objExcel = WIN32OLE.new('Excel.Application')
objExcel.Visible = 1
objExcel.DisplayAlerts = 0 #警告メッセージをOFFobjBook = objExcel.WorkBooks.Open(ARGV[0])
begin
objBook.WorkSheets.each do |sheet|
puts(sheet.Name)
end
ensure
objBook.Close
objExcel.Quit
end
C:\>ruby c:\study\php\chapter004\lesson001.rb c:\study\Book1.xls
Sheet1
Sheet2
Sheet3