Closed
Description
OS (e.g. Windows 10 or macOS Sierra)
Windows 10 Version 1809
Versions of xlwings, Excel and Python (e.g. 0.11.8, Office 365, Python 3.7)
Xlwings 0.19.4
Excel 2016 (16.0.5017.1000) 32bit
Python 3.8.3
Describe your issue (incl. Traceback!)
When calling a aync_mode "threading" function from excel it throws an exception that the "Unique" worksheet function doesn't exist in the WorksheetFunction com object.
It appears a recent change was made to determine if excel support dynamic array by testing if calling Unique throws a com exception of type 0x80020009 (hex(struct.unpack("I", struct.pack("i", -2147352567))[0])). The problem might lie in that the Unique is only a recent addition to Excel. The MS documentation notes it's available to MS 365 subscribers on Current Channel.
# Your traceback here
xlwings server running, clsid={506E67C3-55B5-48C3-A035-EED5DEEA7D6D}
Exception in thread Thread-6:
Traceback (most recent call last):
File "threading.py", line 932, in _bootstrap_inner
File "C:\venv\lib\site-packages\xlwings\udfs.py", line 41, in run
if has_dynamic_array(apps[self.pid]):
File "C:\venv\lib\site-packages\xlwings\udfs.py", line 491, in has_dynamic_array
app.api.WorksheetFunction.Unique("dummy")
File "C:\venv\lib\site-packages\win32com\client\__init__.py", line 473, in __getattr__
raise AttributeError("'%s' object has no attribute '%s'" % (repr(self), attr))
AttributeError: '<win32com.gen_py.Microsoft Excel 16.0 Object Library.WorksheetFunction instance at 0x75441680>' object has no attribute 'Unique'
Include a minimal code sample to reproduce the issue (and attach a sample workbook if required!)
To replicate the issue run func2() in code below. func1() works as exptected.
# Your code here
import xlwings as xw
@xw.func
def func1():
return [100, 200]
@xw.func(async_mode="threading")
def func2():
return [300, 400]
if __name__ == "__main__":
xw.serve()