Error: call was rejected by callee while copying excel data into .inc file

Problems with syntax of GAMS
Post Reply
User avatar
roys
User
User
Posts: 8
Joined: 5 years ago

Error: call was rejected by callee while copying excel data into .inc file

Post by roys »

Hello,

I am trying out the following piece of code to copy excel data into a .inc file which can be used later on in my model. The code is as follows

Code: Select all

set t time periods /t1*t624/;
set i generators /i1*i731/;
set b generator blocks /b1*b3/;
set s buses /s1*s313/;

*Demand data
parameter netload(t,s)
$call =xls2gms.exe r=Load!A1:LB625 i=PCM_Data_ii.xlsx o=Netload.inc
$include Netload.inc
;
When i try and run this I initially get an 'Error: Call was rejected by callee' message and the compilation log gives the error message:

Error Messages


282 Unable to open include file

**** 1 ERROR(S) 0 WARNING(S)
GAMS 25.1.1 r66732 Released May 19, 2018 WEX-WEI x86 64bit/MS Windows 05/31/19 13:18:34 Page 3
G e n e r a l A l g e b r a i c M o d e l i n g S y s t e m
Include File Summary


SEQ GLOBAL TYPE PARENT LOCAL FILENAME

1 1 INPUT 0 0 C:\Users\soummyar\Documents\gamsdir\pr
ojdir\My_model\Model.gms
2 8 CALL 1 8 =xls2gms.exe r=Load!A1:LB625 i=PCM_Dat
a_ii.xlsx o=Netload.inc


COMPILATION TIME = 62.032 SECONDS 3 MB 25.1.1 r66732 WEX-WEI


USER: Small MUD - 5 User License G171204:0625AO-GEN
Attachments
PCM_Data_ii.xlsx
(2.21 MiB) Downloaded 212 times
User avatar
bussieck
Moderator
Moderator
Posts: 1033
Joined: 7 years ago

Re: Error: call was rejected by callee while copying excel data into .inc file

Post by bussieck »

The Excel file you uploaded does not have a sheet called Load. There is a sheet called NetLoadRepDays so if I change the range parameter to r=NetLoadRepDays!A1:LB625 everything works as advertised (on my machine). Have you ever successfully worked with xls2gms? Try test model ReadTrnsportData1 from datalib (https://www.gams.com/latest/datalib_ml/ ... Data1.html) and make sure xls2gms works at all. There are some Office versions out there that don't work with OLE which is used in many of the GAMS Excel tools.

You should also try gdxxrw which is our preferred tools to read and write Excel data. Here is the code to

Code: Select all

*Demand data
parameter netload(t,s)
$call =gdxxrw i=PCM_Data_ii.xlsx o=Netload.gdx par=netload rng=NetLoadRepDays!A1:LB625
$if errorlevel 1 $abort problems reading data from Excel
$gdxin Netload.gdx
$load netload 
A few comments:
  • Always check the return code when calling an external program (as shown in the example with the $if errorlevel...)
  • gdxxrw allows to read multiple symbols in one swoop. This is more efficient than calling gdxxrw for each symbol. See the use of @file in example https://www.gams.com/latest/docs/T_GDXX ... T_PAR_DSET
-Michael
Post Reply