Govert,
I encountered the kind of issue as described in this
http://exceldna.codeplex.com/discussions/255330.
After some trial and error, I discovered that when an array is
returned, its orientation is always set to horizontal. Take your
TestArray example:
[ExcelFunction(Description = "TestArray", Category = "test
functions")]
public static object[] TestArray()
{
object[] result = new object[2];
result[0] = 1.1;
result[1] = 2.3;
return result;
}
If this is called over A1:B1, I got the result as expected. If this
is called over A1:A2, I get two 1.1's.
In another project which connects unmanaged C++ code to Excel, I have
an utility function that detects the orientation of the vector by
inspecting the dimension of the XLOPER. Is it possible to incorporate
something similar to ExcelDNA? Thanks.
----------------------
ObjectHandler::CallerDimensions::Type
getCallerDimension()
{
ObjectHandler::Xloper xCaller;
ObjectHandler::Xloper xMulti;
Excel(xlfCaller, &xCaller, 0);
Excel(xlCoerce, &xMulti, 2, &xCaller, TempInt(xltypeMulti));
ObjectHandler::CallerDimensions::Type callerDimensions;
if (xMulti->val.array.rows == 1 && xMulti->val.array.columns > 1) {
callerDimensions = ObjectHandler::CallerDimensions::Row;
} else {
callerDimensions = ObjectHandler::CallerDimensions::Column;
}
return callerDimensions;
}
----------------------