使用ruby从txt数据读取到excel时遇到问题求助
我使用WinXP系统,已安装excel,ruby。源代码和生成的excel文件我已打包上传。问题是,最后怎么还生成一个RESUME.XLW文件?我只需要那个book1.xls文件啊。希望回答者能详细解答一下,我笨。
代码:(压缩包内也包含代码)
require 'win32ole'
excelc=WIN32OLE.new("excel.application")
excelc['Visible']=TRUE
book=excelc.Workbooks.Add()
sheet=book.worksheets(1)
h=1
File.open("data.txt") do |file|
while line=file.gets
v1,v2,v3,v4,v5,v6,v7=line.split
sheet.setproperty('Cells',h,1,v1)
sheet.setproperty('Cells',h,2,v2)
sheet.setproperty('Cells',h,3,v2)
sheet.setproperty('Cells',h,4,v2)
sheet.setproperty('Cells',h,5,v2)
sheet.setproperty('Cells',h,6,v2)
h+=1
end
end
excelc.save()
excelc.ActiveWorkbook.Close(0)
excelc.Quit()