require 'win32ole'
heading = %w(A B C D E F G H I J K L M N O P Q R S T U V W X Y Z AA AB AC AD AE AF AG AH AI)
excel = WIN32OLE.new('excel.application')
excel.visible = true
excel.workbooks.open('f:/12_ruby/pip.xls')
i = 0
File.open('cols.txt') do |file|
while line = file.gets
i += 1
arr = line.split(/\s+/)
range = 'A' + i.to_s + ':' + heading[arr.length - 1] + i.to_s
excel.range(range).value = arr
end
end
|