复制代码代码如下:
<html>
<adal>
<meta http-equiv = contenu tent contenu = "text / html; charset = utf-8">
<Title> Build Document by Script </Title>
<Script Language = "Text / JavaScript">
fonction word_onclick ()
{
var myDocApp = null;
myDocApp = new activeXObject ("word.application");
myDocApp.Application.Visible = true;
var mydoc = myDocApp.documents.add ();
myDocApp.selection.ParagraphFormat.Alignment = 1
myDocApp.Selection.Range.Bold = true;
myDocApp.selection.font.size = 22;
myDocApp.Selection.Text = "请假申请单"
MyDocApp.Selection.Insertafter ("/ n");
MyDocApp.Selection.Moveright (2,10);
MyDocApp.Selection.TypeParagraph ();
mydocapp.selection.font.bold = false;
myDocApp.selection.font.size = 12;
var myTable0 = mydoc.tables.add (myDocApp.Selection.Range, 3,4);
myTable0.Cell (1,1) .Range.Text = "请假人";
myTable0.Cell (1,2) .Range.Text = "张三";
myTable0.Cell (1,3) .Range.Text = "请假时间";
myTable0.Cell (1,4) .Range.Text = "2006-2-10";
myTable0.Cell (2,1) .Range.Text = "工号";
myTable0.Cell (2,2) .Range.Text = "32412";
myTable0.Cell (2,3) .Range.Text = "填表时间";
myTable0.Cell (2,4) .Range.Text = "2006-2-9";
myTable0.Cell (3,1) .Range.Text = "请假原因";
myTable0.Cell (3,2) .Range.Text = "感冒";
myTable0.Cell (3,3) .Range.Text = "处理方式";
myTable0.Cell (3,4) .Range.Text = "病假";
var range = myDocApp.activeDocument.Content;
plage.collapse (0);
range.insertafter ("/ n");
range = myDocApp.activeDocument.Content;
plage.collapse (0);
var myTable2 = myDoc.Tables.add (plage, 1,2);
myTable2.Columns (1) .setWidth (320,2);
myTable2.Cell (1,1) .Range.Text = "申请人签名" // 空格勿删
myTable2.Cell (1,2) .Range.Text = "申请人的签名";
essayer{
myDocApp.activeDocument.Saveas ("e: //javetoword.doc");
} catch (exception) {
alerte ("浏览器安全设置过高, 保存文件到本地失败");
myDocApp.Documents.close ();
MyDocApp.Application.quit ();
myDocApp = null;
window.close ();
}
}
</cript>
</ Head>
<body>
<p> <a href = "javascript: word_onclick ()"> 生成 word </a> </p>
</docy>
</html>