【发布时间】:2022-10-02 19:20:19
【问题描述】:
我正在尝试使用 python win32com.client 在 excel 中添加折线
这是我的代码:
import pythoncom
file = r\"D:\\\\shapes.xlsx\"
import win32com.client as client
import win32api
xl = client.gencache.EnsureDispatch(\"Excel.Application\")
xl.Visible = True
wb = xl.Workbooks.Open(file)
ws = wb.Sheets(1)
# xl.ActiveWindow.DisplayGridlines = False
print(ws.Cells(11, 2).Left)
fr = ws.Shapes.AddShape(1, ws.Cells(11, 2).Left, ws.Cells(11, 2).Top, 100, 100)
sr = ws.Shapes.AddShape(1, ws.Cells(11, 7).Left, ws.Cells(11, 7).Top, 100, 100)
points= client.VARIANT(pythoncom.VT_ARRAY, (( ws.Cells(11, 2).Left, ws.Cells(11, 2).Top), ( ws.Cells(11, 2).Left, Left, ws.Cells(11, 7).Top), (ws.Cells(11, 7).Left, ws.Cells(11, 7).Top)))
l=ws.Shapes.AddPolyline(points)
它给出了错误MemoryError: CreatingSafeArray
如何用python添加折线?
-
ws.Cells(11, 2).Left, Left, ...那个Left看不下去了。
标签: python excel win32com polyline safearray