<HTML> <Head> <Scriptlanguage= "JavaScript"> varOXL; varOWB; functionExportexcel () {Try{ if(OXL==NULL) {OXL= NewActiveXObject ("Excel.Application"); } //var OXL = new ActiveXObject ("Excel.Application");//Create an Excel Application objectOWB=OXL.Workbooks.Add (); //Create a workbook varosheet=Owb.activesheet; //gets the currently active workbook varsel=Document.body.createTextRange (); Sel.movetoelementtext (record); Sel.select (); Sel.execcommand ("Copy"); //CopyOsheet.paste (); //Pasteoxl.visible= true; //set properties for ExcelOxl.usercontrol= true; OXL=NULL; OWB=NULL; Osheet=NULL; }Catch(e) {alert ("to export the table, you must install the Excel spreadsheet software, and the browser must use the ActiveX control, make sure that your browser settings enable all ActiveX controls. "); return ""; } } </Script></Head> <Body> <DivID= "Record"Align= "Center"> <TableBorder= "1"width= "50%"class= "Tabcss titcss"> <TR> <thcolspan= "One"Align= "Left"> <imgsrc= "Images2/fen_sanjiao.gif" />Registered Project Statistics</th> </TR> <TRAlign= "Center"> <TDrowspan= "3">Project Stage</TD> <TDcolspan= "2">Number of items</TD> <TDcolspan= "8">Responsible Unit</TD> </TR> <TRAlign= "Center"> <TDrowspan= "2">Total</TD> <TDrowspan= "2">Specific Gravity</TD> <TDcolspan= "2">Investment Contact Department</TD> <TDcolspan= "2">Integrated Coordination Department</TD> <TDcolspan= "2">Publicity and Research Department</TD> <TDcolspan= "2">Corporate Services Section</TD> </TR> ........... (Middle omitted n more)</Table> <BR> <Center> <inputtype=buttonclass= "IPT"OnClick= "Exportexcel ();"value= "Export Excel" /> </Center> </Div> </Body> </HTML>
JS Export table to Excle