This is an extension of Peter Bartell's suggestion: save the journal as HTML. This script adds the JSL that uses Run Program() with wscript (that runs vbscript) to import the saved HTML file and do some formatting. It is a modification of example #3 in the script 9_RunProgram.jsl from JSL Companion, Applications of the JMP Scripting Language, 2nd edition.
The script is attached.
Names default to here(1);
dt = Open( "$SAMPLE_DATA/Car Poll.jmp" );
obj = dt << Tabulate(
Show Control Panel( 0 ),
Add Table(
Column Table( Grouping Columns( :sex, :marital status ) ),
Row Table( Grouping Columns( :country, :size ) )
)
);
dt1 = obj << Make into Data Table;
nc = ncol(dt1);
Close(dt1,NoSave);
//===== the code below will import the saved html into Excel =====
//assume < 26*26 columns
_alph = Words("ABCDEFGHIJKLMNOPQRSTUVWXYZ","");
_lc = if(nc<27 , _alph[nc],
_alph[floor((nc-1)/26)] || if(mod(nc,26)==0,"Z", _alph[mod(nc,26)])
);
new window("Tabulate", <<Journal);
obj << Journal();
_htmfid = "C:\TEMP\car_tabulate.htm";
_xlsfid = "C:\TEMP\car_tabulate.xlsx";
current journal() << Save HTML(_htmfid);
cmdList={
"On Error Goto 0 'stop the error handler",
"Dim xlApp",
"\[Set xlApp = CreateObject("Excel.Application")]\",
"xlApp.Visible=True",
"\[xlApp.Workbooks.Open ("^_htmfid^")]\",
"xlApp.Rows.WrapText = False",
"xlApp.Wait Now + #0:00:03#",
"\[xlApp.Columns("A:^_lc^").Select]\",
"xlApp.Selection.Columns.Autofit",
"xlApp.Cells(1, 1).Select",
"\[xlApp.ActiveWorkbook.SaveAs ("^_xlsfid^"), 51]\",
"xlApp.Quit"
};
vbsTxt = concat items(cmdList, "\!N"); //add new lines aka CR
vbsTxt = EvalInsert(vbsTxt); //insert the values for _lc, _htmfid, _xlsfid
Save Text File( "c:\temp\jj1.vbs" , vbsTxt);
rp3 = RunProgram(Executable("wscript"),
Options("c:\temp\jj1.vbs"),
ReadFunction("text")
);
Here is a screen shot of the Excel file. It is a standard Excel file with merged cells for row and column headers and values in cells.