return multi dimension array to excel from c++ xll -


this works fine when try pass 1 dimension array

__declspec(dllexport) lpxloper testarray() {     xloper xlvalues[2];     xlvalues[0].xltype = xltypenum;     xlvalues[1].xltype = xltypenum;     xlvalues[0].val.num = 123;     xlvalues[1].val.num = 345;      static xloper xlarray;     xlarray.xltype = xltypemulti | xlbitdllfree;     xlarray.val.array.rows = 2;     xlarray.val.array.columns = 1;     xlarray.val.array.lparray = &xlvalues[0];     return (lpxloper)&xlarray; } 

but when try pass multi dimension array, function returns #num!

__declspec(dllexport) lpxloper testarray1() {     xloper xlvalues[2][2];     xlvalues[0][0].xltype = xltypenum;     xlvalues[0][1].xltype = xltypenum;     xlvalues[1][0].xltype = xltypenum;     xlvalues[1][1].xltype = xltypenum;      xlvalues[0][0].val.num = 123;     xlvalues[0][1].val.num = 456;     xlvalues[1][0].val.num = 345;     xlvalues[1][1].val.num = 43456;      static xloper xlarray;     xlarray.xltype = xltypemulti | xlbitdllfree;     xlarray.val.array.rows = 2;     xlarray.val.array.columns = 2;     xlarray.val.array.lparray = &xlvalues[0][0];     return (lpxloper)&xlarray; } 

any ideas? in advance!!

in both testarray( ) , testarray1( ) xlvalues local variable on stack, freed runtime when function returns. need make xlvalues heap allocated memory work reliably. xll development of dark art. if you're going serious should invest in copy of steve dalton's book.


Comments

Popular posts from this blog

html - height not adding height to a empty div -

Oracle SQL. How to select specific IDs where value of columns specify criteria? -

python - Robot Framework location and name of keyword -