I'm new to writing XLL, Does anyone know how to return a 6x1 array in Excel?
Below is my function (some codes came from another message):
__declspec(dllexport) LPXLOPER12 WINAPI GetArr(char* arg1, char* arg2) { vector<double> arr = functionReturnVector; XLOPER12 list; list.xltype = xltypeMulti | xlbitDLLFree; list.val.array.lparray = new XLOPER12[6]; list.val.array.rows = 6; list.val.array.columns = 1; for(int i = 0; i < 6; ++i) { list.val.array.lparray[i] = arr[i];
[2013-02-23] I am currently reading codes from XLL RETURN ARRAY and reviewing my code, it can compile, but returns 0 ...
__declspec(dllexport) LPXLOPER12 WINAPI GetArr(void) { XLOPER xlArray, xlValues[2]; xlValues[0].xltype = xltypeNum; xlValues[1].xltype = xltypeNum; xlValues[0].val.num = 11; xlValues[1].val.num = 17; xlArray.xltype = xltypeMulti|xlbitDLLFree; xlArray.val.array.rows = 1; xlArray.val.array.columns = 2; xlArray.val.array.lparray = &xlValues; return &xlArray; }
source share