我是编写 XLL 的新手,有人知道如何将 6x1 数组返回到 Excel 吗?
以下是我的功能(一些代码来自其他帖子):
__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]; // error: IntelliSense: no operator "=" matches these operands
}
return &list;
}
[2013-02-23] 目前我从XLL RETURN ARRAY读取代码并查看我的代码,它可以编译但返回 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;
}