JS export form to Excel's instance code _javascript tips

Source: Internet
Author: User
Copy Code code as follows:

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<title> New Document </title>
<meta name= "generator" content= "EditPlus"/>
<meta name= "Author" content= ""/>
<meta name= "keywords" content= ""/>
<meta name= "description" content= ""/>
<script language= "JavaScript" >
function Automateexcel ()
Start Excel and get Application object.
var oXL = new ActiveXObject ("Excel.Application");
Get a new workbook.
var owb = OXL.Workbooks.Add ();
var osheet = Owb.activesheet;
var table = Document.all.data;
var hang = table.rows.length;
var lie = table.rows (0). Cells.length;
ADD table headers going cell by cell.
for (i=0;i{
for (j=0;j<lie;j++)
Osheet.cells (i+1,j+1). Font.Bold = True
Osheet.cells (i+1,j+1). Font.Size = 50
Osheet.cells (i+1,j+1). Alignment = 2
Osheet.cells (i+1,j+1). Value = Table.rows (i). Cells (j). innertext;
oXL.Visible = true;
Oxl.usercontrol = true;

<table border= "1" width= "100%" id= "Data" >
<td> name </td>
&LT;TD colspan= "2" > Age </td>
<td> Birth date </td>
&LT;TD colspan= "2" >8</td>
&LT;TD height= ">1</td>"
&LT;TD height= ">2</td>"
&LT;TD colspan= "2" height= ">4</td>"
<input type= "button" Name= "Out_excel" onclick= "Automateexcel ();" value= "Export to Excel class=" Notprint ">

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.