ilen
ilen

Reputation: 117

data of GAMS in deffrent sheet

I have 2 Set and one parameter, I want to export these data to excel

 set
     j/1*200/
     E(i,j)
     v(i)
     a(i);
     alias(i,j);

I want to have 'v' be Sheet1, 'a' in sheet2 and 'e' in sheet3. I don't know the rng of my set .

whice command is useful?

my try was not true:

my try

execute_unload "result.gdx"  v  a   e
execute 'gdxxrw.exe  result3.gdx o=result3.xlsx par=v  rng=Sheet1'
execute 'gdxxrw.exe  result3.gdx o=result3.xlsx par=a  rng=Sheet2'
execute 'gdxxrw.exe  result3.gdx o=result3.xlsx par=e  rng=Sheet3 '

Upvotes: 0

Views: 46

Answers (1)

Lutz
Lutz

Reputation: 2292

I think you need to change two things:

  • You declared v, a, e as sets, but tried to write them to Excel as parameter. You should change 'par=v' (etc.) to 'set=v'.
  • If you want to specify just the sheet name of a range, it need to end with '!', so change 'rng=Sheet1' to 'rng=Sheet1!' (see here: https://www.gams.com/latest/docs/T_GDXXRW.html#GDXXRW_RANGES).

So, all in all, you should be OK, using this:

 execute 'gdxxrw.exe  result3.gdx o=result3.xlsx set=v  rng=Sheet1!'
 execute 'gdxxrw.exe  result3.gdx o=result3.xlsx set=a  rng=Sheet2!'
 execute 'gdxxrw.exe  result3.gdx o=result3.xlsx set=e  rng=Sheet3!'

Note, that you could actually also do it in one call:

 execute 'gdxxrw.exe  result3.gdx o=result3.xlsx set=v  rng=Sheet1! set=a  rng=Sheet2! set=e  rng=Sheet3!'

And a final note: When using 'execute' in GAMS, it is often useful, to check the errorLevel right after the call.

Upvotes: 2

Related Questions