XLL+ Class Library

CXlOper::FromVector() Example

#include <algorithm>

// Function:    XlOperFromVectorEx
// Purpose:     Returns a sorted vector

//{{XLP_SRC(XlOperFromVectorEx)
    // NOTE - the FunctionWizard will add and remove mapping code here.
    //    DO NOT EDIT what you see in these blocks of generated code!
IMPLEMENT_XLLFN2(XlOperFromVectorEx, "RP", "XlOperFromVectorEx",
    "Input", "Demo Functions", "Returns a sorted vector", 
    "Vector of numbers", "B()Input Vector of numbers\0", 1)

extern "C" __declspec( dllexport )
LPXLOPER XlOperFromVectorEx(const COper* Input)
{
    CXlOper xloResult;
    BOOL bOk = TRUE;
    std::vector<double> vecInput;
    bOk = bOk && Input->ReadVector(vecInput, "Input", xloResult);
    if (!bOk)
        return xloResult.Ret();
//}}XLP_SRC

    std::sort(vecInput.begin(), vecInput.end());
    xloResult.FromVector(vecInput);
    return xloResult.Ret();
}

Uses

CXlOper::FromVector