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

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -