向大侠们求教:   
          我做了一个用javascript向word文档中替换字符串的程序,碰到了这个问题。   
  doc文档中有这样一节文字   
      "....本季度的销售额{@xxxxxxxxxxxxx@},..."我想将xxxxxxxxxxxxx(但是xxxxxxxxxxxxx不是固定的)   
  读出来,并替换成其他内容,我该怎样做呢?   
    
  还望大家不吝赐教,谢谢了!!!!   
  谢谢了!!!!!  

解决方案 »

  1.   

    此回复为自动发出,仅用于显示而已,并无任何其他特殊作用
    楼主【zb_01】截止到2008-07-23 08:48:52的历史汇总数据(不包括此帖):
    发帖的总数量:1                        发帖的总分数:100                      每贴平均分数:100                      
    回帖的总数量:0                        得分贴总数量:0                        回帖的得分率:0%                       
    结贴的总数量:0                        结贴的总分数:0                        
    无满意结贴数:0                        无满意结贴分:0                        
    未结的帖子数:1                        未结的总分数:100                      
    结贴的百分比:0.00  %               结分的百分比:0.00  %                  
    无满意结贴率:---------------------无满意结分率:---------------------
    如何结贴请参考这里:http://topic.csdn.net/u/20080501/09/ef7ba1b3-6466-49f6-9d92-36fe6d471dd1.html
      

  2.   

    js读word 好像是 word.application 的activex插件,具体的不清楚,你要查下
      

  3.   

    有这么个插件,可以操作word和excel
      

  4.   

    ok,搞定了!下面是自己写的javascript,想实现该功能的,自己看程序吧!
    function FormListToDoc(filename){
    if (filename==''){
    alert('程序没有配置需要打印的文档模版!');
    return;
    }
    alert('请准备好打印机和纸张,并设定IE相关配置(工具-internet选项-高级-urf8传送-去掉)');
      var wdapp=new ActiveXObject("Word.Application");
    wdapp.visible=true;
    wddoc=wdapp.Documents.Open(filename);

    var tab = document.getElementById('mytable');   
    var row=tab.rows.length;
    var column=tab.rows(1).cells.length;
    var selected=false;
    //处理循环书签
    if (wdapp.ActiveDocument.Books.Exists("loop")){
    var bkmloop = wdapp.ActiveDocument.Books("loop");
    bkmloop.select();
    wdapp.Selection.copy();
    //alert(wdapp.Selection.text);
    }
    if (wdapp.ActiveDocument.Books.Exists("loop")){
    var loop=0;
    for(i=1;i<row;i++){
    for(j=0;j<column;j++){
    var obj = tab.rows(i).cells(j).all[0];
    if (typeof(obj)=="object"){
    var tagName = obj.tagName.toUpperCase();
    if (tagName=='INPUT' || tagName=='SPAN'){
    var vcolumnname = obj.name;
    if (vcolumnname.toLowerCase().indexOf("select")>-1){
    if (obj.checked==true){
    n=i-1;
    wdapp.Selection.Find.Execute("_0", false,false, false, false, false, true, 1, true, "_"+n, 2);
    wdapp.Selection.paste();
    }
    }
    }
      }
    }
    }
    }
    //处理替换
    for(i=1;i<row;i++){
    for(j=0;j<column;j++){
    var obj = tab.rows(i).cells(j).all[0];
    if (typeof(obj)=="object"){
    var tagName = obj.tagName.toUpperCase();
    if (tagName=='INPUT' || tagName=='SPAN'){
    var vcolumnname = obj.name;
    if (vcolumnname.toLowerCase().indexOf("select")>-1){
    selected = obj.checked;
    }else{
    if (selected==true){
    vvalue = obj.innerText;
    wdapp.Selection.Find.ClearFormatting();
    wdapp.Selection.Find.Replacement.ClearFormatting();
    wdapp.Selection.Find.Execute(vcolumnname, false,false, false, false, false, true, 1, true, vvalue, 2);
    }
    }
    }
    }
    }
    }
    wdapp=null;
    }