Excel 2007中的数据透视图的自动化

你能帮我一下,以便自动化一个数据透视表,下面是我写的代码。 我目前正在创build一个图表

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}") 

这与Watir无关。 Watir驱动浏览器。 你想要驱动Excel。 这可以帮助: 使用Ruby自动化Excel

进入Excel并logging一个macros,在其中创build一个数据透视表。 然后看看macros源代码,并将其转换为ruby或AutoIt或Watir或其他任何你想使用…