JS Export table to Excle

Source: Internet
Author: User

<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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.