If you have a group of vector arguments which are closely related, and are always the same size as each other, then you may want to use a column group. The user will then see only one argument, and the wizard will generate code to split it into a number of vectors, checking that each column is present and that all columns are the same length.
Column groups can be useful for both the add-in developer and the user.
Column groups are not always a useful feature.
For example, take a grouped argument, PaymentSchedule, that contains two columns, as follows:
Name | Type |
---|---|
PaymentDate | Double |
PaymentAmount | Double |
The XLL+ Function Wizard will generate code that declares a vector of the appropriate type for each column and populates it with the contents of the corresponding column of input. If the input cannot be read, then an appropriate error message will be returned.
// Function: RevalSchedule // Purpose: Revaluate a stream of payments //{{XLP_SRC(RevalSchedule) // NOTE - the FunctionWizard will add and remove mapping code here. // DO NOT EDIT what you see in these blocks of generated code! IMPLEMENT_XLLFN2(RevalSchedule, "RBP", "RevalSchedule", "ValueDate,PaymentSchedule", "Financial", "Revaluate a" " stream of payments", "Date of evaluation\02 columns:" " PaymentDates; PaymentAmounts", "\0B()PaymentDates \0+B(" ")PaymentAmounts \0", 1) extern "C" __declspec( dllexport ) LPXLOPER RevalSchedule(double ValueDate, const COper* PaymentSchedule) { CXlOper xloResult; BOOL bOk = TRUE; std::vector<double> vecPaymentDates; bOk = bOk && PaymentSchedule->ReadVector(vecPaymentDates, "PaymentSchedule", xloResult, 0, 0); std::vector<double> vecPaymentAmounts; bOk = bOk && PaymentSchedule->ReadVector(vecPaymentAmounts, "PaymentSchedule", xloResult, 0, 1); if (!bOk) return xloResult.Ret(); //}}XLP_SRC // TODO - Set the value of xloResult return xloResult.Ret(); }
If the input-checking code fails, then a useful error message will be returned, such as:
#Error in cell 3 of PaymentSchedule column 1 (PaymentDates): expected a number
or:
#Error column 2 of PaymentSchedule: expected 4 rows
If all the input-checking code is successful, then the variables vecPaymentDates and vecPaymentAmounts will be populated and ready for use. In addition, both vectors will be the same length.
There are two ways to create a column group in the Function Wizard.