Hi,
For now dynamic array formulas are prefixed with the implicit intersection operator (@) when using threading on generated user defined functions.
Meaning that a single value is shown instead of the expected array.
import xlwings as xw
@xw.func(async_mode='threading')
def many_values():
return ["test", "test2"]

The issue comes from the fact that Range.Formula is used when updating the formula to trigger a new call retrieving the cached result:
|
apps[self.pid].books[self.book].sheets[self.sheet][self.address].formula = \ |
Leading to the underlying use of Range.Formula as in the following:
Switching to Range.Formula2 fixes the issue.

I will gladly provide a pull request but I was wondering about the design approach for this fix, so first I would like to check with you if the following can be merged:
However I would point out that I don't have access to a Mac then I am unable to test the behavior on Mac, that's why I am proposing to use a try/except block on the operation, as I am unaware of the result.
Also, I don't have access to a version of Microsoft Excel that does not have Range.Formula2, so I am unable to test the behavior when Range.Formula2 is not available, that's why I am proposing to use a try/except block on the operation, as I am unaware of the result.
According to my tests, Range.Formula2 works fine with arrays and single value return types.
Hi,
For now dynamic array formulas are prefixed with the implicit intersection operator (@) when using threading on generated user defined functions.
Meaning that a single value is shown instead of the expected array.
The issue comes from the fact that Range.Formula is used when updating the formula to trigger a new call retrieving the cached result:
xlwings/xlwings/udfs.py
Line 39 in 7af1737
Leading to the underlying use of Range.Formula as in the following:
xlwings/xlwings/_xlwindows.py
Line 743 in 7af1737
Switching to Range.Formula2 fixes the issue.

I will gladly provide a pull request but I was wondering about the design approach for this fix, so first I would like to check with you if the following can be merged:
formula2(as a property, the same way it is done forformula) insidexlwings._xlwindows.Rangeandxlwings._xlmac.Rangeclasses.xlwings.udfs.AsyncThread.run, try to setformula2with the previousformula2, if it fails, fallback to previous behavior (settingformulawith the previousformula).However I would point out that I don't have access to a Mac then I am unable to test the behavior on Mac, that's why I am proposing to use a try/except block on the operation, as I am unaware of the result.
Also, I don't have access to a version of Microsoft Excel that does not have Range.Formula2, so I am unable to test the behavior when Range.Formula2 is not available, that's why I am proposing to use a try/except block on the operation, as I am unaware of the result.
According to my tests, Range.Formula2 works fine with arrays and single value return types.