views:

464

answers:

1

This VBA macro works:

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

This Python (near) Equivalent almost works:

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

Apart from the last bit - I can't get the chart type to be "xlLine" (plain line graph). Any ideas ?