【问题标题】:Python win32com: Excel set chart type to LinePython win32com:Excel 将图表类型设置为 Line
【发布时间】:2010-02-04 23:41:16
【问题描述】:

此 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 (near) 等效项几乎可以工作:

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

除了最后一点 - 我无法将图表类型设置为“xlLine”(纯线图)。 有什么想法吗?

【问题讨论】:

  • xlLine 对我来说很好,但 xlColumn 和 xlBar 不行。事实上,除了 xlLine 似乎什么都没有。有什么想法吗?

标签: python excel charts python-2.6 win32com


【解决方案1】:
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2019-08-24
  • 2020-01-29
  • 1970-01-01
  • 2015-05-26
  • 2010-10-26
  • 1970-01-01
相关资源
最近更新 更多