从xlwings公司获得电话单的正确方法是什么?

2024-04-19 08:47:21 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用RunPython已经有一段时间了,它是excelvba的下面的结构

Sub GetModel()
    RunPython ("from [...] import fill_model; fill_model()") 
End Sub

python函数如下所示,在我更新到xlwings 0.15.6之前,它一直都在工作。在

^{pr2}$

现在我在从Excel运行时出现以下异常:

Exception: Book.caller() must not be called directly. Call through Excel or set a mock caller first with Book.set_mock_caller().

但是,这不是我从excel调用的模拟调用者设置。我知道我可以使用类似wb = Book('name_of_sheet.xlsm')这样的调用,但有时用户在使用工作表时会重命名它。怎样才能拿到电话单?在


Tags: fromimportmodel结构excelfillmockend