作家
登录

几个javascript操作word的参考代码

作者: 来源:www.28hudong.com 2013-03-30 02:12:45 阅读 我要评论

复制代码 代码如下:/* ??给几个js写word的参考: ??this.Word.Selection.Font.Size = 16; //字体大小 ??this.Word.Selection.Font.Bold = true; //是否加粗 ??this.Word.Selection.ParagraphFormat.Alignment = 2; //0左对齐,1居中,2右对齐,数字只能0-9,慢慢试吧 ??this.Word.Selection.InsertRowsBelow(1); //下面加入一行 ??this.Word.Selection.MoveRight(1); //光标右移 ??this.Word.Selection.TypeText(string); //只能写string ??this.Word.Selection.MoveDown(); //光标下移 ??this.Word.Selection.EndKey(); //光标移动到末尾 ??this.Word.ActiveDocument.Sections(1).Headers(1).Range.InsertAfter(string); //写页眉,结尾处写 ??this._LoadData = function () { ??//替换函数,用于替换$strFld$类型的文本 ?? function replace( Range, strFld ) { ??//[FindText], [MatchCase], [MatchWholeWord], [MatchWildcards], [MatchSoundsLike], [MatchAllWordForms], [Forward], [Wrap], [Format], [ReplaceWith], [Replace], [MatchKashida], [MatchDiacritics], [MatchAlefHamza], [MatchControl] ?? Range.Find.Execute( "$"+strFld+"$", true, false, false, false, false, true, wdFindContinue, false, getElValue("l"+strFld) ) ?? } ??//初始化Word控件 ?? this._InitWord = function () ?? { ?? try{ ?? this.Word = new ActiveXObject("Word.Application"); ?? this.Word.visible = true; ?? this.Doc = this.Word.Documents.Open( this.TemplatePath ); ?? this.Doc.Activate(); ?? this.Range = this.Doc.Range(); ?? return true ?? } catch(e) { ?? //TODO: 如果用户手动取消ActiveX的运行,则会留一WINWORD.EXE的进程。 ?? //除非"设为可信站点,并在自定义级别里将第二项启用",则不会出现启用ActiveX的对话框。 ?? try { ?? if ( this.Doc ) { this.Doc.Close(0) }; ?? if ( this.Word ) { this.Word.Quit() } ?? } ?? catch (e){} ?? return false ?? } ?? } ??*/

  推荐阅读

  jQuery 判断元素上是否绑定了事件

我研究了一下之后发现,jQuery都将事件缓存起来了,其实也是为了防止内存溢出以及页面unload的时候的速度,也包括多函数触发,方便管理等诸多好处,具体可以参考此文。 jQuery会在window.unload的时候卸载所有绑定>>>详细阅读


本文标题:几个javascript操作word的参考代码

地址:http://www.17bianji.com/kaifa2/JS/27836.html

关键词: 探索发现

乐购科技部分新闻及文章转载自互联网,供读者交流和学习,若有涉及作者版权等问题请及时与我们联系,以便更正、删除或按规定办理。感谢所有提供资讯的网站,欢迎各类媒体与乐购科技进行文章共享合作。

网友点评
自媒体专栏

评论

热度

精彩导读
栏目ID=71的表不存在(操作类型=0)