When using async_mode='threading'
I noticed the following behaviour:
@xw.func(async_mode='threading')
@xw.ret(expand='table')
def test_fun():
time.sleep(2)
return [[0], [1], [2]]
The above code will output correctly 0, 1, 2 but this will output an array (ie the excel formula will have the {} brackets) and it will overwrite anything below it, ie won't use that spill warning and you can't edit it without editing the entire array.
@xw.func(async_mode='threading')
def test_fun():
time.sleep(2)
return [[0], [1], [2]]
This however which seems more desirable as it outputs a dynamic array (were I to remove the async_mode) only outputs 0 and the formula turns into @test_fun() and thus only returns the first value.
Experiencing this behaviour on v0.15.8
Your second example is the correct way of doing it and works for me. The first version is only if you specifically want to work with the legacy CSE arrays which is normally only the case when your version of Excel is not supporting dynamic arrays.
Just make sure to delete the CSE version of your formula completely, then re-import the function and simply call =test_fun()
from a cell in Excel.
This should work from version v0.19.0 onwards - this was the issue that was being experienced. OP had v0.15.8.