复制代码代码如下:
<html>
<head>
<meta http-equiv = content-type content = "text/html; charset = utf-8">
<title> สร้างเอกสารด้วยสคริปต์ </title>
<script language = "text/javascript">
ฟังก์ชั่น 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 = myDocApp.activeDocument.content;
range.collapse (0);
range.insertafter ("/n");
range = myDocApp.activeDocument.content;
range.collapse (0);
var mytable2 = mydoc.tables.add (ช่วง, 1,2);
MyTable2.Columns (1) .SetWidth (320,2);
myTable2.cell (1,1) .Range.Text = "申请人签名" // 空格勿删
MyTable2.Cell (1,2) .Range.Text = "申请人的签名";
พยายาม{
myDocApp.activedocument.saveas ("e: //javetoword.doc");
} catch (ข้อยกเว้น) {
การแจ้งเตือน ("浏览器安全设置过高, 保存文件到本地失败");
myDocApp.documents.close ();
myDocApp.application.quit ();
myDocApp = null;
window.close ();
-
-
</script>
</head>
<body>
<p> <a href = "javascript: word_onclick ()"> 生成 word </a> </p>
</body>
</html>