使用ruby从txt数据读取到excel时遇到问题求助

weedor 2008-11-28 02:56:52
我使用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()
...全文
104 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
weedor 2008-11-28
  • 打赏
  • 举报
回复
晕啊,发完了发觉标题很别扭,但是又没有权限修改。版主帮个忙啊。我想把“从”字改成“把”字是不是合适一点呢。

2,763

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 Ruby/Rails
社区管理员
  • Ruby/Rails社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧