各位大侠们  如何利用 js 将一个完整的html页面导入到word.页面中有图片 并且不只一个表格。求高手帮助;
像下面这样的代码没用function AllAreaWord()
  {
  var oWD = new ActiveXObject("Word.Application");
  var oDC = oWD.Documents.Add("",0,1);
  var oRange =oDC.Range(0,1);
  var sel = document.body.createTextRange();
  sel.moveToElementText(PrintA);
  sel.select();
  sel.execCommand("Copy");
  oRange.Paste();
  oWD.Application.Visible = true;
  //window.close();
  }

解决方案 »

  1.   

    //找别人的,试试吧
    直接用word打开,然后存成.doc文件就可以了。 protected   void   ConvertToHtml(string   SrcFilePath,string   TargetFilePath) 

        Word.Application   app=new   Word.Application(); 
        app.Visible=false; 
        Object   o=Missing.Value; 
        object   docFile=SrcFilePath; 
        _Document   doc=app.Documents.Open(ref   docFile,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o); 
        object   fileName=TargetFilePath; 
        object   format=Word.WdSaveFormat.wdFormatDocument;   //word   format 
        doc.SaveAs(ref   fileName,ref   format,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o,ref   o); 
        object   t=true; 
        app.Quit(ref   t,ref   o,ref   o); 

      

  2.   

    用js?!有难度
    用POI包可以编码操作word表格
      

  3.   

    var save = function(content, name){
        var f = document.createElement('iframe');
        f.style.display = 'none';
        document.appendChild(f);
        window[window.length - 1].document.write(content);
        window[window.length - 1].document.execCommand('saveas', true, name);
        document.removeChild(f);
    };save('<html>' + document.documentElement.innerHTML + '</html>', document.title + '.doc');
      

  4.   

    这种与WORD的接口操作,现在很多浏览器都禁掉的,最可靠的就是copy then paste