我正在尝试更改 Excel(实际上是 PowerPoint)图表的值。我尝试通过传递一个数组来做到这一点,但它似乎不起作用。尽管如本页所述,它应该可以工作......:http: //msdn.microsoft.com/en-us/library/office/ff746833.aspx
那么我的代码目前看起来如何:
require 'win32ole'
mspp_app = WIN32OLE.new("Powerpoint.Application")
mspp = mspp_app.Presentations.Open(pathToFile)
slide = mspp.Slides(1)
shapes = slide.shapes
chartshape = shapes(3) #the chart happens to be shape n°3
chart = chartshape.chart
# now get the seriescollection
sc = chart.SeriesCollection
sc3 = sc.Item(3)
values = sc3.values #returns the current values as an array example: [1.0, 1.0, 5.0, 2.0]
# now set the values
sc3.values = [2.0, 2.0, 5.0, 1.0] # returns no error
# see if the values are set
values = sc3.values # returns an empty Array []
以前有人试过吗?