Question

Cette macro fonctionne VBA:

Sub Draw_Graph()
    Columns("A:B").Select
    ActiveSheet.Shapes.AddChart.Select
    ActiveChart.SetSourceData Source:=ActiveSheet.Range("$A:$B")
    ActiveChart.ChartType = xlLine
End Sub

Python (près) équivalent fonctionne presque:

from win32com import client

excel=client.Dispatch("Excel.Application")
excel.Visible=True
book=excel.Workbooks.Open("myfile.csv", False, True)
sheet=book.Worksheets(1)
chart=book.Charts.Add()
chart.SetSourceData(sheet.Range("$A:$B"))
chart.ChartType=client.constants.xlLine

A part le dernier bit - je ne peux pas obtenir le type de graphique à être « xlLine » (graphique ligne simple). Toutes les idées?

Était-ce utile?
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top