xlwings - Automation error for simple UDF function setting cell value

…衆ロ難τιáo~ 提交于 2021-01-29 07:06:40

问题


I have a fairly basic function that is supposed to set a cell value (in theory a DataFrame, but I've replaced that with 1 as part of my debugging).

@xl.func
def RT_GetChartData():
    excel = xl.Book.caller()
    excel.app.display_alerts = False      #I do this because I keep getting OLE errors
    
    excel.sheets("EventDates").range("TempEventOutput").value = 1
    return "done"

When I call this function from Excel, it sometimes sets the cell to 1 (but not every time, as I've replaced that with 2, 3, etc and doesn't update), and the cell returns simply

"Automation error"

Any ideas on whats going on... ? I've confirmed that the object types are correct, ie Book, Sheet, Range, so I dont think it's that...

来源:https://stackoverflow.com/questions/65112975/xlwings-automation-error-for-simple-udf-function-setting-cell-value

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!