First of all I know that the question was already asked here :
return multi dimension array to excel from c++ xll
I have tried to revive the subject, without suc
A simple example returning a 5*5 matrix. Don't forget to free the allocated array via the xlAutoFree12
function.
__declspec(dllexport) LPXLOPER12 WINAPI Get2DArray(void)
{
static XLOPER12 xlArray;
int rows = 5;
int cols = 5;
xlArray.xltype = xltypeMulti | xlbitDLLFree;
xlArray.val.array.rows = rows;
xlArray.val.array.columns = cols;
xlArray.val.array.lparray = reinterpret_cast(::malloc(rows * cols * sizeof(XLOPER12)));
for (int r=0;rxltype = xltypeNum;
var->val.num = r*c;
}
}
return &xlArray;
}