$title Writing to Spreadsheet using the merge and clear Option (GDXXRWExample12,SEQ=024) $onText This program illustrates the use of merge and clear option when writing to a spreadsheet range with matching row and column labels already stored within the spreadsheet. This model is referenced in "Writing to Spreadsheet with merge Option" resp. "Writing to Spreadsheet with clear Option" from the GDXXRW Documentation. $offText $callTool win32.msappavail Excel $if errorlevel 1 $abort.noError "No Excel available" * Writing to Spreadsheet with merge Option * defining the parameter we want to write to spreadsheet Parameter A / brussels.chicago.ship 6000 brussels.cleveland.ship 5000 "san francisco".chicago.truck 3000 "san francisco".cleveland.rail 2000 "san francisco".cleveland.truck 2200 /; * unload the data $gdxOut data.gdx $unLoad A $gdxOut * use an option file to increase readability $onEcho > howToWrite.txt par=A rng=merge_clear!B1:G4 rDim=2 cDim=1 merge par=A rng=merge_clear!B8 rDim=2 cDim=1 $offEcho $call gdxxrw data.gdx output=exampleData.xlsx @howToWrite.txt trace=0 $ifE errorLevel<>0 $abort Error writing to spreadsheet merge_clear with merge enabled! *------------------------------------------------------------------------------- * Writing to Spreadsheet with clear Option * The data is already stored in data.gdx. We write to spreadsheet using the following statement: $call gdxxrw data.gdx output=exampleData.xlsx par=A rng=merge_clear!I1 rDim=2 cDim=1 clear trace=0 $ifE errorLevel<>0 $abort Error writing to spreadsheet merge_clear with clear enabled!