XLL+ Class Library

CXlOper::AllocArray() Example

//{{XLP_SRC(AllocArrayEx)
    // NOTE - the FunctionWizard will add and remove mapping code here.
    //    DO NOT EDIT what you see in these blocks of generated code!
IMPLEMENT_XLLFN2(AllocArrayEx, "R", "AllocArrayEx", "", 
    "Demo functions", "Returns a mixed array of data", "", "", 1)

extern "C" __declspec( dllexport )
LPXLOPER AllocArrayEx()
{
    CXlOper xloResult;
//}}XLP_SRC

    // Allocate an array of empty cells
    USHORT cRows = 3, cCols = 2;
    xloResult.AllocArray(cRows, cCols);

    // Set each cell
    for (USHORT i = 0; i < cRows; i++) {
        // Put a number in the first cell
        xloResult.Cell(i, 0) = (double)i;
        // Put a string in the second cell
        CString strFormat;
        strFormat.Format("String %d", i);
        xloResult.Cell(i, 1) = strFormat;
    }

    // Return the array to Excel
    return xloResult.Ret();
}

Uses

CXlOper::AllocArray | CXlOper::Format | CXlOper::Cell