2011-05-16 63 views
0

请帮我看一下透视图的自动化,下面是我写的代码。我目前正在创建图表excel 2007中透视图的自动化

require "rubygems" 
# require "watir" # Commented out by editor to the question, not by the OP 
require 'win32ole' 

excel=WIN32OLE.new("Excel.Application") 
excel.visible=true 
work_book=excel.Workbooks.Open("C:\\VAMSI\\PIVOTAL_CHART_CODE\\pivotal.xlsx") 
worksheet = work_book.worksheets(1) 
worksheet.range("a1").select 
autoit= WIN32OLE.new("AutoItX3.Control") 
autoit.Send("!n") 
autoit.Send("!v") 
autoit.Send("!t") 
autoit.Send("{ENTER}") 

回答

3

这与Watir无关。 Watir驱动浏览器。你想要驱动Excel。这可能有所帮助:Automating Excel with Ruby

+0

感谢您的快速答复Željko菲律宾,我知道这是不涉及watir,我有做了几件事情的Excel自动化,但在这里我想创建一个数据透视表,并没有想法做到这一点。 – Vam 2011-05-16 08:20:20

+0

我不知道什么是数据透视图。如果你知道这个问题与Watir无关,你为什么要标记它? :) – 2011-05-16 11:23:36

+0

它不应该被标记为watir,它完全关于win32ole对象,问题是如何使用ruby自动化Micorsoft Excel数据透视图:) – Vam 2011-05-16 12:40:26

1

进入excel并记录一个您创建数据透视表的宏。然后看看宏源代码,并将其转换为红宝石或AutoIt或Watir或任何其他你觉得使用...