Skip to content

Instantly share code, notes, and snippets.

@fornext1119
Created April 11, 2012 13:56
Show Gist options
  • Save fornext1119/2359458 to your computer and use it in GitHub Desktop.
Save fornext1119/2359458 to your computer and use it in GitHub Desktop.
Ruby で Excel のシート名一覧を出力
require 'win32ole'
excelApp = WIN32OLE.new('Excel.Application')
excelApp.Visible = 1
excelApp.DisplayAlerts = 0 #警告メッセージをOFF
#ブックを読み取り専用で開く
book = excelApp.WorkBooks.Open(ARGV[0], false, true)
book.WorkSheets.each do |sheet|
puts(sheet.Name)
end
book.Close
excelApp.Quit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment