StabiloHB
StabiloHB

Reputation: 13

CPLEX read excel by index

How can I read a tuple from excel on cplex by its index note the cell. I mean :

T from SheetRead(sheet,"'Data'!(0,0)");

Instead of :

T from SheetRead(sheet,"'Data'!A1");

I have tuple that can be longer or shorter between different simulation. The lenght is define by n. May I do a thing like :

T from SheetRead(sheet,"'Data'!(0,0):(0,n)");

thank have a good day

Upvotes: 1

Views: 209

Answers (1)

Daniel Junglas
Daniel Junglas

Reputation: 5940

The answers to your questions can be found in the reference documentation of function SheetRead:

  1. Usually, you can use Excel's R1C1 notation to index cells purely by index. Unfortunately, this is not supported by OPL.
  2. The arguments to function SheetRead can only be string literals. So you cannot use variables there.

One option in your case would be to define a named range in the Excel sheets. For example, you can define a named range called "TupleData" in each of the different sheets and define that range to be of different dimension/location in different sheets. Then in the .dat file you can write

T from SheetRead(sheet, "'Data'!TupleData");

Upvotes: 1

Related Questions