Heim  >  Artikel  >  Web-Frontend  >  js word表格动态添加代码_javascript技巧

js word表格动态添加代码_javascript技巧

WBOY
WBOYOriginal
2016-05-16 18:25:291467Durchsuche
复制代码 代码如下:

<script> <BR>function wordcontorl(){ <BR>alert("小孟佳的宝贝"); <BR>var WordApp=new ActiveXObject("Word.Application"); <BR>var wdCharacter=1 <BR>var wdOrientLandscape = 1 <BR>WordApp.Application.Visible=true; //执行完成之后是否弹出已经生成的word <BR>var myDoc=WordApp.Documents.Add();//创建新的空文档 <BR>WordApp.ActiveDocument.PageSetup.Orientation = wdOrientLandscape//页面方向设置为横向 <BR>WordApp. Selection.ParagraphFormat.Alignment=1 //1居中对齐,0为居右 <BR>WordApp. Selection.Font.Bold=true <BR>WordApp. Selection.Font.Size=20 <BR>WordApp. Selection.TypeText("孟佳烧香"); <BR>WordApp. Selection.MoveRight(wdCharacter);    //光标右移字符 <BR>WordApp.Selection.TypeParagraph()         //插入段落 <BR>WordApp. Selection.Font.Size=12 <BR>WordApp. Selection.TypeText("-----朱漪编写"); //分行插入日期 <BR>WordApp.Selection.TypeParagraph()         //插入段落 <BR>var myTable=myDoc.Tables.Add (WordApp.Selection.Range, 8,7) //8行7列的表格 <BR>//myTable.Style="网格型" <BR>var aa = "孟佳标题" <BR>var TableRange; //以下为给表格中的单元格赋值 <BR>for (i= 0;i<7;i++) <BR>{ <BR>with (myTable.Cell(1,i+1).Range) <BR>{ <BR>font.Size = 12; <BR>InsertAfter(aa); <BR>ColumnWidth =4 <BR>} <BR>} <BR>for (n =0;n<7;n++) <BR>{ <BR>for (i =0;i<7 ;i++) <BR>{ <BR>with (myTable.Cell(i+2,n+1).Range) <BR>{font.Size = 12; <BR>InsertAfter("孟佳小可爱"); <BR>} <BR>} <BR>} <BR>row_count = 0; <BR>col_count = 0 <BR>myDoc.Protect(1) <BR>} <BR>wordcontorl() <BR></script>

每种功能的实现方法有很多,希望各位可以交流不同的思想和方法。可以加QQ412546724。呵呵
Stellungnahme:
Der Inhalt dieses Artikels wird freiwillig von Internetnutzern beigesteuert und das Urheberrecht liegt beim ursprünglichen Autor. Diese Website übernimmt keine entsprechende rechtliche Verantwortung. Wenn Sie Inhalte finden, bei denen der Verdacht eines Plagiats oder einer Rechtsverletzung besteht, wenden Sie sich bitte an admin@php.cn