Return two dimensional array to excel from a c++ xll, the come back

后端 未结 1 1296
粉色の甜心
粉色の甜心 2021-01-22 04:40

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

1条回答
  •  囚心锁ツ
    2021-01-22 04:57

    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;
    }
    

    0 讨论(0)
提交回复
热议问题