现在的位置: 首页 > 综合 > 正文

用javascript生成word文件及文件预览

2013年10月21日 ⁄ 综合 ⁄ 共 403字 ⁄ 字号 评论关闭

  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(position);
  sel.select();
  sel.execCommand("Copy");
  oRange.Paste();
  oWD.ActiveDocument.PageSetup.LeftMargin = 60;
  oWD.Application.Visible = true;
  oWD.activate();
  oWD.ActiveWindow.ActivePane.view.Type=3;  //默认为页面视图
  //oDC.PrintPreview(); //设置为预览

抱歉!评论已关闭.