XLL+ Class Library

CXlArray::Ret

Prepares a CXlArray to be returned as a value to Excel

[C++]
LPXLARRAY Ret();

Return value

This function returns a pointer to some static memory containing a copy of this CXlArray.

Remarks

The Ret() function is essential to the implementation of the memory management features of the library. When you return data to Excel from an add-in function, the data must be contained in memory which remains in scope even when the function goes out of scope.

The Ret() function takes the current value in the CXlArray and copies it into heap memory. It then releases the memory of the original copy and sets flags in the new copy so that Excel will properly manage the memory clean-up on your behalf.

Once you have called Ret(), a CXlArray is no longer valid, and cannot be used for any purpose.

Ret() is only used in the return statements of add-in functions, for example:

CXlArray xlaResult;
std::vector<double> vecResult;
vecResult.push_back(1.0);
vecResult.push_back(2.0);
xlaResult = vecResult;
return xlaResult.Ret();

Requirements

Header: xllplus.h

See Also

CXlArray Class | CXlArray Methods