SheetWrite works only when you have Excel and a Windows machine. If you do not you may export your result into a csv file instead.
If you use CPLEX 20.1 you may use CSVPublish
If you do not, see How to export into a csv file ? in How to with OPL ?
execute
{
// turn an OPL tupleset into a csv file
function turnTuplesetIntoCSV(tupleSet,csvFileName)
{
var f=new IloOplOutputFile(csvFileName);
var quote="\"";
var nextline="\\\n";
var nbFields=tupleSet.getNFields();
for(var j=0;j<nbFields;j++) f.write(tupleSet.getFieldName(j),";");
f.writeln();
for(var i in tupleSet)
{
for(var j=0;j<nbFields;j++)
{
var value=i[tupleSet.getFieldName(j)];
if (typeof(value)=="string") f.write(quote);
f.write(value);
if (typeof(value)=="string") f.write(quote);
f.write(";");
}
f.writeln();
}
f.close();
}
}
tuple t
{
string firstname;
int number;
}
{t} s={<"Nicolas",2>,<"Alexander",3>};
execute
{
turnTuplesetIntoCSV(s,"export.csv");
}