Created
February 25, 2012 13:53
-
-
Save y-yagi/1908583 to your computer and use it in GitHub Desktop.
カレントディレクトリ配下のExcelを全て印刷するRubyスクリプト
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -*- coding: cp932 -*- | |
require 'find' | |
require 'win32ole' | |
def getAbsolutePath filename | |
fso = WIN32OLE.new('Scripting.FileSystemObject') | |
return fso.GetAbsolutePathName(filename) | |
end | |
xl = WIN32OLE.new('Excel.Application') | |
xl.DisplayAlerts = false | |
xl.Visible = true | |
Find.find('.') do |file| | |
next unless file.match(/\.xlsx?\z/) | |
book = xl.Workbooks.Open(getAbsolutePath(file)) | |
book.Worksheets.select | |
book.PrintOut | |
book.Close | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment