- <html>
- <head>
- <title>web横向导出word</title>
- <script type="text/javascript">
- function AutomateWord(tableid,reportName)
- {
- try{
- var oWD = new ActiveXObject("Word.Application");
- }catch(e){
- alert("无法调用Office对象,请确保您的机器已安装了Office并已将本系统的站点名加入到IE的信任站点列表中!");
- return;
- }
- //默认为页面视图
- var oDC = oWD.Documents.Add("",0,0);
- oWD.ActiveDocument.PageSetup.TopMargin = 2.5/0.035;
- oWD.ActiveDocument.PageSetup.LeftMargin = 2.5/0.035;
- oWD.ActiveDocument.PageSetup.BottomMargin = 2.5/0.035;
- oWD.ActiveDocument.PageSetup.RightMargin = 2.5/0.035;
- //oWD.ActiveDocument.PageSetup.LinesPage = 0;
- var oRange =oDC.Range(0,1);
- var sel = document.body.createTextRange();
- sel.moveToElementText(tableid);
- sel.select();
- sel.execCommand("Copy");
- oRange.Paste();
- //oWD.ActiveDocument.ActiveWindow.View.Type=3 //设定显示为页面视图状态
- oWD.ActiveWindow.Caption=reportName;
- oWD.Application.DefaultSaveFormat = "doc"
- oWD.Application.Visible = true;
- }
- </script>
- <style type="text/css">
- span.pagebreak{line-height: 125%;}
- span br.brbreak{page-break-before: always; mso-break-type: section-break;}
- div.Section1{page: Section1;}
- div.Section2{page: Section2;}
- @page Section2{size: 29.7cm 21.0cm;mso-page-orientation: landscape; }
- </style>
- </head>
- <body>
- <div>
- <input id="btnDc" type="button" value="导出" οnclick="AutomateWord(dc,'web横向导出word')" />
- </div>
- <div id="dc" style="width:21cm; padding:2.52cm auto; margin-right:auto; margin-left:auto;">
- <div class="Section1">
- 排版:竖
- </div>
- <span class="pagebreak">
- <br clear="all" class="brbreak" />
- </span>
- <div class="Section2">
- 排版:横
- </div>
- <!--------------此处换页符不可省略,否则无法横向导出-------------->
- <span class="pagebreak">
- <br clear="all" class="brbreak" />
- </span>
- </div>
- </body>
- </html>
web 横向导出word
最新推荐文章于 2021-06-03 23:39:49 发布