$title	Generate an Excel Table with Labelled Rows and Columns

SET	S /p1 product 1, p2 product 2/,
	I /I1 Item 1, I2 Item 2/;

TABLE X (S,I) Table to be generated
        I1      I2
P1      2       3
P2      4       7

execute_unload 'x.gdx',x,s,i;

$onecho >gdxxrw.rsp
set=s rng=a4 rdim=1 cdim=0 values=string
set=i rng=d1 rdim=0 cdim=1 values=string
set=s rng=c4 rdim=1 cdim=0 values=nodata
set=i rng=d3 rdim=0 cdim=1 values=nodata
par=x rng=c3 rdim=1 cdim=1 merge
$offecho

*	Delete x.xls if it exists, as this script is setup
*	up to work with a "virgin" worksheet:

$if exist x.xls $call del x.xls
execute 'gdxxrw i=x.gdx o=x.xls @gdxxrw.rsp trace=3 log=x.log'


$onecho >cleanup.vbs
dim objFSO
Set objFSO = CreateObject("Scripting.FileSystemObject")
dim xlsfile
xlsfile =  "x.xls"
xlsfile = objFSO.GetAbsolutePathName(xlsfile)
public objExcel         ' Excel instance
Set objExcel = CreateObject("Excel.Application")
objExcel.visible = False
dim wb
set wb=objExcel.Workbooks.Open(xlsfile)
dim ws
dim xlup,xltoleft
xlup = -4162
xltoleft = -4159
set ws=wb.Worksheets(1)
ws.Rows(1).EntireRow.Delete xlup
ws.Columns(1).EntireColumn.Delete xltoleft
ws.Rows(2).EntireRow.Hidden = True
ws.Columns(2).EntireColumn.Hidden = True
objExcel.DisplayAlerts = False
objExcel.Save
objExcel.Application.quit
$offecho
execute 'cleanup.vbs';