gdxxrw5.gms : Test for password handling of gdxxrw

Description

This model reads from and writes to password protected xlsx sheet using the
password option of GDXXRW. Also it makes sure that $hiddenCall is hidden,
even with $onDollar and dp=2

Contributor: Jan-H. Jagla, September 2009


Small Model of Type : GAMS


Category : GAMS Test library


Main file : gdxxrw5.gms

$title 'Test for password handling of gdxxrw and $hiddenCall' (GDXXRW5,SEQ=458)

$onText
This model reads from and writes to password protected xlsx sheet using the
password option of GDXXRW. Also it makes sure that $hiddenCall is hidden,
even with $onDollar and dp=2

Contributor: Jan-H. Jagla, September 2009
$offText

$callTool win32.msappavail Excel
$if errorlevel 1 $abort.noError "No Excel available"

$onEcho > runme.gms
Sets
    i   canning plants   / seattle, san-diego /
    j   markets          / new-york, chicago, topeka / ;

parameter
    x(i,j);

$onDollar
$hiddenCall gdxxrw gdxxrw5.xlsx password="this is a test" par=x trace=0
$if errorlevel 1 $abort 'gdxxrw read call failed'
$gdxIn gdxxrw5
$load x
$offDollar
$offEcho

*First test that $hiddenCall is hidden
$call gams runme.gms lo=2 dp=2
$if errorlevel 1 $abort 'gams runme execution failed'
$call grep password runme.log  > problem
$call grep password runme.lst >> problem
$call test -s problem
$if errorlevel 1 $goTo done
$abort 'GDX failed but normal completion'
$label done


*Now test reading and writing to password-protected Excel file
$include runme.gms

Table x2(i,j)  distance in thousands of miles
                    new-york       chicago      topeka
      seattle          50            300
      san-diego        275                        275  ;

display x,x2;

abort$sum((i,j),abs(x(i,j)-x2(i,j)) > 0) 'Data differs';

execute_unload 'test2' x2;
execute 'gdxxrw test2.gdx o=gdxxrw5.xlsx password="this is a test" index=gdxxrw5 trace=0';
abort$errorlevel 'gdxxrw write call failed'