XLL+ Class Library

Compressed groups

A compressed group can contain any number of scalar (single-cell) arguments. Each of these inner arguments must be defined as one of the following types:

Appearance in Excel

The four inner arguments will appear in Excel as a single array argument. For example, take a group argument, PaymentDetails, that contains four inner arguments, as follows:

Name Type
StartDate Double
EndDate Double
AccountType String
PaymentDays Long

The wizard will generate code that inspects the outer (Excel) argument. This code will fail and return a helpful error message unless the argument is one of the following shapes:

Wizard-generated code for compressed groups

The wizard-generated code to unpack this group will look like this:

extern "C" __declspec( dllexport )
LPXLOPER GroupedFn(const COper* PaymentDetails)
{
    CXlOper xloResult;
    BOOL bOk = TRUE;
    double StartDate;
    bOk = bOk && PaymentDetails->ReadVectorItem(StartDate, "PaymentDetails", 0, "StartDate", xloResult);
    double EndDate;
    bOk = bOk && PaymentDetails->ReadVectorItem(EndDate, "PaymentDetails", 1, "EndDate", xloResult);
    short AccountType;
    bOk = bOk && PaymentDetails->ReadVectorItem(AccountType, "PaymentDetails", 2, "AccountType", xloResult);
    long PaymentDays;
    bOk = bOk && PaymentDetails->ReadVectorItem(PaymentDays, "PaymentDetails", 3, "PaymentDays", xloResult);
    if (!bOk)
        return xloResult.Ret();
//}}XLP_SRC

    ...
}

If the input-checking code fails, then a useful error message will be returned, such as:

#Error in cell 4 of PaymentDetails (PaymentDays): expected an integer

If all the input-checking code is successful, then the variables StartDate, EndDate, AccountType and PaymentDays will be populated and ready for use.

Creating a compressed group

There are two ways to create a compressed group in the Function Wizard.

  1. You can set the argument type to Group in the arguments grid.
  2. You can use the Edit Groups command to display the Groups dialog, which lets you add existing arguments to a group, and rearrange the members of column groups and compressed groups.

Example

You can see an example of grouped arguments in use in the LabelledArgs sample project.

Next: Column groups >>