and call this from an excel as an array function, passing it a cell range containing say ('a','b','c', 'd'), in it returns the first element len(x) (e.g. four) times. The same is true if I simply just return x.
Is it possible to return lists, or only tuples? Can the data in the tuple or list be heterogeneous, say both strings and ints/floats?
Thanks again!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I think your problem is more to do with Excel than ExcelPython - try
inserting the array function the other way i.e. horizontally (1x4)
instead of vertically (4x1).
This is just what Excel does when you return a 1D array, it displays
it horizontally and repeats it vertically. You can of course use
Excel's built-in TRANSPOSE function to turn it the other way.
In future I might add a feature to sort this out from Python directly however.
You can return both list and tuples, and the elements can be any type
that can be represented in an Excel cell (i.e. not dictionaries for
example)
Thanks for your interest in ExcelPython!
Eric
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Eric,
If you could sort this out in Python, it would be great. I'm running into the same problem with a 2 column return; if there is only one row it repeats both columns for the whole array in Excel... Right now I test for it in my UDF and append an empty row at the end since I am totalling one of the returned columns in Excel.
Thanks,
Eric
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Eric~
Thank you for your tremendous work! The new add-in is great!
Could you also give an example of how to return multidimensional data from python to Excel, via the add-in? For example, if I try the function:
@xlfunc
@xlarg("x", dims=1)
def reverse_list(x):
x_reversed = x[::-1]
return x_reversed
and call this from an excel as an array function, passing it a cell range containing say ('a','b','c', 'd'), in it returns the first element len(x) (e.g. four) times. The same is true if I simply just return x.
Is it possible to return lists, or only tuples? Can the data in the tuple or list be heterogeneous, say both strings and ints/floats?
Thanks again!
Thanks very much for the appreciation!
I think your problem is more to do with Excel than ExcelPython - try
inserting the array function the other way i.e. horizontally (1x4)
instead of vertically (4x1).
This is just what Excel does when you return a 1D array, it displays
it horizontally and repeats it vertically. You can of course use
Excel's built-in
TRANSPOSE
function to turn it the other way.In future I might add a feature to sort this out from Python directly however.
You can return both list and tuples, and the elements can be any type
that can be represented in an Excel cell (i.e. not dictionaries for
example)
Thanks for your interest in ExcelPython!
Eric
Hi Eric,
If you could sort this out in Python, it would be great. I'm running into the same problem with a 2 column return; if there is only one row it repeats both columns for the whole array in Excel... Right now I test for it in my UDF and append an empty row at the end since I am totalling one of the returned columns in Excel.
Thanks,
Eric