Copy codeThe Code is as follows: function copyToExcel (tableid ){
// Control button
Var btn = document. getElementById ("copy ");
Btn. setAttribute ("disabled", "true ");
Btn. setAttribute ("value", "processing ...");
Var curTbl = document. getElementById (tableid );
Try {
Var oXL = new ActiveXObject ("Excel. Application ");
}
Catch (e) {// if the security level of IE is not set, an error will occur (the Automation server cannot create an object)
/*
If Scripting. FileSystemObject (FSO text file read/write) is disabled, enable the FSO function and execute regsvr32 scrrun. dll in "run ".
*/
Alert ("cannot start Excel! \ N if you are sure that Excel, "+" is installed on your computer, adjust the security level of IE. \ N specific operation: \ n "+" Tools → Internet Options → Security → User-Defined Level → initialize and Run ActiveX programs not marked as secure → enable ");
Return false;
}
Var oWB = oXL. Workbooks. Add ();
Var oSheet = oWB. ActiveSheet;
Var sel = document. body. createTextRange ();
Sel. moveToElementText (curTbl );
Sel. select ();
Sel.exe cCommand ("Copy ");
OSheet. Paste ();
OXL. Visible = true;
Var fname = oXL. Application. GetSaveAsFilename ("Export tableto excel.xls", "Excel Spreadsheets (*. xls), *. xls ");
OWB. SaveAs (fname );
OWB. Close ();
OXL. Quit ();
// Control button
Btn. removeAttribute ("disabled ");
Btn. setAttribute ("value", "Export result to Excel ");
}