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 ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title> Untitled Document </title>
<script language= "JavaScript" >
function automatewordautopaging (prefixion,count)
{
var OWD = new ActiveXObject ("Word.Application");
var ODC = OWD.Documents.Add ();
Odc.showgrammaticalerrors = false; Screen grammar checking
Odc.showspellingerrors = false; Screen spell check
var oRange =odc.range (0,1);
for (i=0;i<count;i++)
{
var sel = Document.body.createTextRange ();
var tablename = Prefixion+i;
var Table = document.getElementById (tablename)
Sel.movetoelementtext (Table);
Sel.select ();
Sel.execcommand ("Copy");
OWD.Selection.Paste ();
OWD.Selection.InsertBreak (); Insert Page Break
}
Owd.activedocument.activewindow.view.type=3//Set Browse mode
Owd.visible = true;
};
function Automateexcel (prefixion)
{
var eltable = document.getElementById ("Automateexcel");
var orangeref = Document.body.createTextRange ();
Orangeref.movetoelementtext (eltable);
Orangeref.execcommand ("Copy");
try{
var appexcel = new ActiveXObject ("Excel.Application");
}catch (e)
{
Alert ("Cannot call Office objects, make sure your machine has Office installed and added the site name of this system to the list of trusted sites for IE!") ");
Return
}
Appexcel.visible = true;
APPEXCEL.WORKBOOKS.ADD (). Worksheets.item (1). Paste ();
Appexcel.workbooks (1). Worksheets.item (1). Columns ("A:a"). ColumnWidth = 100;
Appexcel.workbooks (1). Worksheets.item (1). Columns ("B:b"). ColumnWidth = 21;
Appexcel = null
};
</script>
<body>
<input type= button value= Export to Word auto page "onclick=" automatewordautopaging (' Table ', 5)/>
<input type= "button" value= "Export to Excel Control column width" onclick= "automateexcel (' Table ')"/>
<div id= "Automateexcel" >
<table class=tabp id= "Table0" cellspacing=0 cellpadding=2 "width=" 100% align=center
<TR>
<TD width= "100%" align= "center" > title 0</td>
</TR>
<TR>
<TD align= "center" > Content 0</td>
</TR>
</TABLE>
<BR>
<table class=tabp id= "Table1" cellspacing=0 cellpadding=2 "width=" 100% align=center
<TR>
<TD width= "100%" align= "center" > title 1</td>
</TR>
<TR>
<TD align= "center" > Content 1</td>
</TR>
</TABLE>
<BR/>
<table class=tabp id= "Table2" cellspacing=0 cellpadding=2 "width=" 100% align=center
<TR>
<TD width= "100%" align= "center" > title 2</td>
</TR>
<TR>
<TD align= "center" > Content 2</td>
</TR>
</TABLE>
<BR/>
<table class=tabp id= "Table3" cellspacing=0 cellpadding=2 "width=" 100% align=center
<TR>
<TD width= "100%" align= "center" > title 3</td>
</TR>
<TR>
<TD align= "center" > Content 3</td>
</TR>
</TABLE>
<BR/>
<table class=tabp id= "Table4" cellspacing=0 cellpadding=2 "width=" 100% align=center
<TR>
<TD width= "100%" align= "center" > title 4</td>
</TR>
<TR>
<TD align= "center" > Content 4</td>
</TR>
</TABLE>
<BR/>
</div>
</body>