从xlwings调用Pycharm时的断点

从xlwings调用python代码时,我无法获得断点。

testme.py:

import xlwings as xw def add(n): result = [] while len(result) < n: result.append(1+4) return result def xl_add(): sht = xw.Book.caller().sheets[0] n = sht.range('B1').options(numbers=int).value seq = add(n) sht.range('C1').expand('vertical').clear_contents() sht.range('C1').options(transpose=True).value = seq if __name__ == "__main__": xw.serve() 

我用这个VBA代码在同一个目录下保存了一张XL表格:

 Sub CallTestMe() RunPython ("import testme; testme.xl_add()") End Sub 

在xlwings.bas我更改设置为:

 PYTHON_WIN = "D:\Anaconda3\python.exe" UDF_DEBUG_SERVER = True 

然后我启动了pycharm,并在add(n)中设置了一个断点,并启动了debugging器。

 D:\Anaconda3\python.exe "D:\Program Files\JetBrains\PyCharm Community Edition 2017.1.4\helpers\pydev\pydevd.py" --multiproc --qt-support --client 127.0.0.1 --port 18601 --file D:/sletmig/xlwings/testme.py pydev debugger: process 8684 is connecting Connected to pydev debugger (build 171.4694.38) xlwings server running, clsid={506E67C3-55B5-48C3-A035-EED5DEEA7D6D} 

我调用VBA代码,并在列C中返回5行, 但没有发生断点 。 在B1单元格中,我有一个数字10。

软件版本
Pycharm社区版2017.4
xlwings v0.10.4
Python 3.6.1 :: Anaconda 4.4.0(32位)
Office 2013 32位
Windows 10,64位

只有在这些UDF函数中设置断点才是可能的:

 @xw.func def double_sum(x, y): """Returns twice the sum of the two arguments""" return 2 * (x + y) def main(): # To run this with the debug server, set UDF_DEBUG_SERVER = True in the xlwings VBA module xw.serve() if __name__ == '__main__': main() 

断点是当您在Pycharm中启动服务器并从XL = DOUBLE_SUM(1,2)调用它时,