Function makeexcel (OBJ, procevisible, saveasfilename, sorttype, sortfield )...{
VaR mydata = new gettabledata (OBJ, 0, 0 );
VaR myrows = mydata. Rows;
VaR I, J;
Try ...{
VaR XLS = new activexobject ("Excel. application ");
}
Catch (e )...{
Alert ("to print this table, you must install the Excel spreadsheet software, and the browser must use the" ActiveX Control ". Your browser must allow the execution of the control. Click [help] to learn about browser settings! ");
Return "";
}
If (typeof (procevisible) = "undefined ")...{
XLS. Visible = true;
}
Else ...{
If (procevisible = "true ")...{
XLS. Visible = true;
}
Else
...{
XLS. Visible = false;
}
}
VaR xlbook = XLS. workbooks. Add;
VaR xlsheet = xlbook. worksheets (1 );
XLS. cells. Select;
XLS. selection. numberformatlocal = "@";
For (I = 0; I <mydata. Rows; I ++ )...{
For (j = 0; j <mydata. Cols; j ++ )...{
If (typeof (mydata. getfielddata (j) = "Number ")...{
Xlsheet. cells (I + 1, J + 1). numberformatlocal = "0.00 _";
}
Xlsheet. cells (I + 1, J + 1). value = mydata. getfielddata (j );
}
Mydata. movenext ();
}
If (saveasfilename = "" | typeof (saveasfilename) = "undefined ")...{
VaR fname = XLS. application. getsaveasfilename ("*. xls", "Excel spreadsheets (*. xls), *. xls ");
If (fname! = "")...{
Xlbook. saveas (fname );
}
}
Else ...{
Xlbook. saveas (saveasfilename );
}
Xlbook. Close (savechanges = false );
// XLS. Visible = false;
XLS. Quit ();
XLS = NULL;
// Ends the Excel process and exits
Window. setinterval ("cleanup ();", 1 );
}