XLL+ Class Library (6.3)

Arrays of mixed type

Sometimes your results will not be in ready-made vector or imtx form, and you'll need to use a different technique to populate xloResult.

CXlOper::FromDoubleArray

The simplest method to use is CXlOper::FromDoubleArray(), to populate the xloResult, using an array of values or of pointers to rows/columns of values.

The various different versions of this method are listed below:

CXlOper::AllocArray

A more complex way to populate an array result is by using CXlOper::AllocArray() to create the array, and then CXlOper::Cell() to populate each cell.

While this method involves more programming, it gives you full control over the output, and allows you to have mixed data types in the array.

Say we want to return a mixed array of names and prices:

CopyC++
const char* names[] = { "ACME", "ULTRA", "CHEESECO" };
double prices[] = { 100.0, 1234.5, 0.0 };

xloResult.AllocArray(3, 2);
for (int i = 0; i < 3; i++)
{
    xloResult.Cell(i, 0) = names[i];
    xloResult.Cell(i, 1) = prices[i];
}
return xloResult.Ret();

The result will look like this:

See the CXlOper::AllocArray() example for another example of this technique.

Next: Value lists >>