Auto resizing of async functions is not supported by PyXLL.
Instead, we recommend that you return an "object" from your async function and have a second synchronous function to expand it. The return type of the second function may be an array type, e.g. "int[]", or the "var" type in which case PyXLL will determine the type automatically from the returned list.
For example,
import asyncio
from pyxll import xl_func
@xl_func("int length: object", auto_resize=False)
async def array_function(length):
coroutine = lambda: asyncio.sleep(5)
await coroutine()
return [0 for _ in range(length)]
@xl_func("object x: var", auto_resize=True)
def expand_array(x):
return x # No need to do anything here,
# the PyXLL type conversion will do the work.
In Excel, you would call your async function "array_function", which would return the array as an object. Then, you would call "expand_array" to expand the array object into an Excel range.