Direct reference to Microsoft's COM is to generate word, the following is a description of the implementation of the JavaScript code
The code is as follows: <html> <head> <meta http-equiv=content-type content= "Text/html;charset=utf-8" > <title>build Document by script</title> <script language= "Text/javascript" > function 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= "Leave request Form" 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= "Leave person"; Mytable0.cell (1,2). range.text= "John"; Mytable0.cell (1,3). Range.text= "Leave Time"; Mytable0.cell (1,4). range.text= "2006-2-10"; Mytable0.cell (2,1). range.text= "Work number"; Mytable0.cell (2,2). range.text= "32412"; Mytable0.cell (2,3). range.text= "Filling time"; Mytable0.cell (2,4). range.text= "2006-2-9"; Mytable0.cell (3,1). range.text= "Reason for absence"; Mytable0.cell (3,2). range.text= "Cold"; Mytable0.cell (3,3). range.text= "processing mode"; Mytable0.cell (3,4). range.text= "sick leave"; var range=mydocapp.activedocument.content; range. Collapse (0); range.insertafter ("n"); range=mydocapp.activedocument.content; range. Collapse (0); var mytable2=mydoc.tables.add (range,1,2); mytable2.columns (1). SetWidth (320,2); Mytable2.cell (1,1). range.text= "Applicant Signature"//Space not deleted Mytable2.cell (1,2). range.text= "Applicant's signature"; try{ myDocApp.ActiveDocument.SaveAs ("E:javetoword.doc"); }catch ( Exception) { alert ("Browser security settings are too high, save files to local failure"); MyDocApp.Documents.close (); Mydocapp.appLication.quit (); mydocapp=null; window.close (); } } </SCRIPT> </head > <BODY> <p><a href= "Javascript:word_onclick ()" > Generation word</a></p> </BODY> </HTML>