|
Xlexport |
Top Previous Next |
|
The procedure Xlexport can be used to export data from a GAMS program into a spreadsheet. It writes data into spreadsheets only when it finds row and column labels that match the set elements within the specified target range. Those elements also control element ordering. Command format is that above requiring specification of
There is also an optional merge parameter telling whether to leave preexisting data with nonmatching data elements alone. Example: Solve tranport using lp minimizing totalcost ; $libinclude xlexport transport.l myspread.xls output3!a1..d4 $libinclude xlexport transport.m myspread.xls output3!f1..i4 $libinclude xlexport transport.l myspread.xls output3!a6:d8 /m $libinclude xlexport transport.l myspread.xls output3!f6:i9 /m
This copies the data for the solution levels (.l) or marginals (.m) of the variable named transport into the spreadsheet called myspread.xls into various ranges depending on the statement. The first command exports the data after the solve statement into the sheet called output3 in the range a1 to d4. The third command exports the data after the solve statement into the sheet called output3 in the range a6 to d8 merging in the results.
The output3 sheet before the import looks like
and the sheet afterward looks like
where the order of the results varies according the order in which the column labels and row labels appear in the spreadsheet. Also note under the merge option that the data present in the spreadsheet before the export remain afterward when the labels do not match as in the case of the random column in column D rows 6-7. The exports other than the first one do not fully match all of the column dimensionality of the transport.l item and thus only export subsets of the items. Notes:
|