ruby-win32ole活用
- 摘要:require'win32ole'excel=WIN32OLE.new("excel.application")excel.visible=true#~book=excel.workbooks.add()#创建文件book=excel.workbooks.open("d:\\tt.xls")worksheet=book.worksheets(1)#以下为写入文件。#~worksheet.Range("A1:D1").value=["North","South","East","West"]
- 标签:Ruby
require 'win32ole'
excel = WIN32OLE.new("excel.application")
excel.visible = true
#~ book = excel.workbooks.add() #创建文件
book = excel.workbooks.open("d:\\tt.xls")
worksheet = book.worksheets(1)
#以下为写入文件。
#~ worksheet.Range("A1:D1").value = ["North","South","East","West"];
#~ worksheet.Range("A2:B2").value = [5.2, 10];
#~ worksheet.Range("C2").value = 8;
#~ worksheet.Range("D2").value = 20;
a = worksheet.range("A2:E11").value
pp a #读取单元格值
b = worksheet.range("A2:E11")
puts b.rows.count #获取行数,不含标题行
puts b.columns.count #获取列数
#~ puts worksheet.columns
#~ range = worksheet.Range("A1:D2");
#~ range.select
#~ chart = book.Charts.Add;
#~ book.saveas "..." #另保存路径
#~ book.save
book.close
excel.Quit;