I'm writing some code for an assignment, and I need to create a simple column chart in Excel. This afternoon I found win32com (amazing tool by the way), but I've been suffering from either the lack of documentation about it, or my lack of luck to find it ^^
I'm playing around with the charts, and I think I've managed to do what I want, with a little exception: the function I wrote always creates 2 series of columns.
This is what I've got:
xlBook = xlApp.Workbooks.Add()
xlSheet = xlBook.Sheets(1)
xlSheet.Name = "Algoritmos de Busqueda"
xlSheet.Cells(1,1).Value="Secuencial"
xlSheet.Cells(2,1).Value="Binaria"
xlSheet.Cells(1,2).Value="32"
xlSheet.Cells(2,2).Value="32"
chart = xlApp.Charts.Add()
chart.Name= "Grafico "+xlSheet.Name
series = chart.SeriesCollection().NewSeries()
valoresx=xlSheet.Range("A1:A2")
valoresy=xlSheet.Range("B1:B2")
series.XValues= valoresx
series.Values= valoresy
series.Name= "Algoritmos"
xAxis= chart.Axes()[0]
yAxis= chart.Axes()[1]
xAxis.HasMajorGridlines = True
yAxis.HasMajorGridlines = True
I create a new series inside the chart, and it contains all the info I need. However, when I run the script, I end up with an Excel chart with 4 columns, with the same info (in pairs). I've done everything I can, but I just can't find what's creating this second series of values on the X axis...
I greatly appreciate any help ^^ Thanks!