|
The procedure Xlimport imports data from a spreadsheet into a GAMS program. Its format is that above requiring specification of the
| • | Name of the item to have data imported into it. |
| • | The location in the sheet including source sheet name and cell range. |
Example:
(fromExcel.gms)
set places /newyork,chicago,topeka,totalsupply/
destinaton(places)
sources /seattle,sandiego,totalneed/
source(sources);
destinaton(places)=yes;
destinaton("totalsupply")=no;
source(sources)=yes;
source("totalneed")=no;
parameter trandata (sources,places) transport data from spreadsheet
Supply(Sources) Supply at each source plant in cases
Need(places) Amount neeeded at each market destination in cases;
$libinclude xlimport trandata myspread.xls input!a1:e4
This copies the data for the GAMS parameter named trandata from the spreadsheet called myspread.xls from the sheet called input from the range a1 to e4.
Notes:
| • | The use of Xlimport permits simplicity of data transfer, but is not as versatile as the use of Gdxxrw as described below. |
| • | Xlimport is designed to allow one to import set names but this only works under a row vector of set element names. Users wishing to import set element names from the spreadsheet should use Gdxxrw. |
| • | The use of Xlimport to import data requires that the set elements have already been specified in explicit set statements. |
| • | Xlimport is restricted to compile time imports only. Data imports during execution time must use Gdxxrw or the GAMS from GAMS procedure discussed below. |
| • | Xlimport being a compile time import does domain checking to make sure the set element names in the range match. |
| • | Current procedures do not allow import of attributes of variables or equations but this may be fixed by the time this manual is made available. |
|