Description
This program illustrates reading a set from an Excel spreadsheet using 'values' option. This model is referenced in "Reading Set Elements associated with Data or Text using the values Option" from the GDXXRW Documentation.
Category : GAMS Data Utilities library
Main file : GDXXRWExample9.gms includes : exampleData.xlsx GDXXRWExample9.gms
$title Reading Set Elements associated with Data or Text using the values Option (GDXXRWExample9,SEQ=020)
$onText
This program illustrates reading a set from an Excel
spreadsheet using 'values' option.
This model is referenced in "Reading Set Elements associated with Data or Text
using the values Option" from the GDXXRW Documentation.
$offText
$callTool win32.msappavail Excel
$if errorlevel 1 $abort.noError "No Excel available"
Set
A_yn 'results for reading with values=yn'
A_dense 'results for reading with values=dense'
A_sparse 'results for reading with values=sparse'
A_noData 'results for reading with values=noData'
A_auto 'results for reading with values=auto';
* Parameter file to icrease readability
$onEcho > howToRead.txt
set=A_yn rng=readingWithValues!A1:M2 cDim=1 values=yn
set=A_dense rng=readingWithValues!A1:M2 cDim=1 values=dense
set=A_sparse rng=readingWithValues!A1:M2 cDim=1 values=sparse
set=A_noData rng=readingWithValues!A1:M2 cDim=1 values=noData
set=A_auto rng=readingWithValues!A1:M2 cDim=1
$offEcho
$call gdxxrw exampleData.xlsx output=readingWithValues.gdx @howToRead.txt trace=0
$ifE errorLevel<>0 $abort Error reading sheet readingWithValues!
* Load the data
$gdxIn readingWithValues.gdx
$load A_yn A_dense A_sparse A_noData A_auto
$gdxIn
* Based on the rng, cDim, rDim specifications, the default valueType is dense
* Hence, A_auto and A_dense are equal!
display A_yn, A_dense, A_sparse, A_noData, A_auto;