Procedure Spreadsheet::RetrieveSet(Workbook, Set, Range, Sheet, Mode)


The procedure Spreadsheet::RetrieveSet fills an AIMMS set based on the data in the given range of an Excel or OpenOffice Calc workbook.

        Workbook,       ! (input) scalar string expression
        Set,            ! (output) set identifier
        Range,          ! (input) scalar string expression
        [Sheet],        ! (optional) scalar string expression
        [Mode]          ! (optional) scalar element expression



A scalar string expression representing the Excel or Calc workbook. If this argument ends in .ods, OpenOffice Calc is used. Otherwise, Excel is


The set to be filled.


The range in the workbook based on which the Set must be filled.


The sheet from which the data should be read. Default is the active sheet.


Element in the pre-defined set MergeReplace. In replace mode, the AIMMS set is emptied before being filled. In merge mode, the new elements are added to the existing set. By default, the set is filled in replace mode.

Return Value

The procedure returns 1 on success, or 0 otherwise. In case of an error the pre-defined AIMMS parameter CurrentErrorMessage contains a description of what went wrong.


  • By calling the procedure Spreadsheet::SetActiveSheet you can set the active sheet, after which the optional sheet argument can be omitted in procedures like this one.

  • A call to this procedure with a specified sheet argument does not change the active sheet, except when the workbook does not have an active sheet yet.

  • Upto AIMMS 3.11 this function was known as ExcelRetrieveSet, which has become deprecated as of AIMMS 3.12.